Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2012-05-09 06:46:08

kr37
Member
From: Colorado
Registered: 2011-11-06
Posts: 28

Re: How do I add new elements (such as a pop-up form) in the Write tab?

OK, it’s coming along. Thank you for all the help so far. What I’ve got now is an event calendar with a simple graphical updater(ajax) on the write tab. For the server-side ajax, I’ve had to create a page template. Now to make it a cleaner plugin, I’d like that server-side ajax to happen as a function inside the plugin. It seems like I want to register a callback for sanitize_for_url and apply a dumbdown rule? I’m feeling a bit clueless here (what’s a dumbdown rule?).

My idea is that the write-tab javascript calls textpattern with a url like /gkr_ajax_calendar, and that invokes a function inside the plugin. Any suggestions?

Offline

#17 2012-05-09 16:00:10

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: How do I add new elements (such as a pop-up form) in the Write tab?

I’ve done something like this to call a function within my plugin and output data.

if (@txpinterface == 'admin') {
	switch(gps('xxx_gps')) {
		case 'js':
			xxx_output_js();
			break;
		case 'ajax':
			xxx_get_ajax_data();
			break;
		default:
			break;
	}

} 

Then you can use a url like ?xxx_gps=ajax to get to the outputed data or a script tag to pull in your js.

<script type="text/javascript" src="?xxx_gps=js"></script>

There may be a better way but this has worked for me.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#18 2012-05-10 02:31:14

kr37
Member
From: Colorado
Registered: 2011-11-06
Posts: 28

Re: How do I add new elements (such as a pop-up form) in the Write tab?

Matt, that’s very nice and beautiful. Thank you.

Offline

#19 2012-10-16 02:05:58

kr37
Member
From: Colorado
Registered: 2011-11-06
Posts: 28

Re: How do I add new elements (such as a pop-up form) in the Write tab?

Hello, I’ve been using a kludge made of my own calendar plugin and smd_calendar for a few months, with smd_calendar drawing the calendar from a separate event database. Now I’m trying to clean up my calendar plugin, so it draws its own calendar. What I don’t understand is, why is the output of my plugin appearing at the very beginning of the page, before the DOCTYPE? Here is my page template, it should draw the calendar twice, first using my plugin, and then using smd_calendar—-and it does this, but my calendar appears before the doctype. Any hints what I’m doing wrong?

<txp:output_form form="std-page-1header" />
<txp:output_form form="std-page-2nav" />
<!-- Content -->
<div id="main_calendar">

<txp:gkr_cal_display/>

<txp:smd_calendar stepfield="custom_2" omitfield="custom_3" extrafield="custom_4" firstday="0" dayformat="{Sun,Mon,Tue,Wed,Thu,Fri,Sat}" cellform="calendar-cellform" xform="calendar_event" class="calendar" select="month, year" navarrow="<--, -->" />

</div main_calendar>
<txp:output_form form="std-page-4footer" />

Offline

#20 2012-10-16 14:45:39

kr37
Member
From: Colorado
Registered: 2011-11-06
Posts: 28

Re: How do I add new elements (such as a pop-up form) in the Write tab?

Sorry, I worked it out, have to “return” the results and not just echo them out!

Offline

#21 2012-10-16 15:26:46

etc
Developer
Registered: 2010-11-11
Posts: 5,689
Website GitHub

Re: How do I add new elements (such as a pop-up form) in the Write tab?

kr37 wrote:

I need to know the article number of the article being edited on the write tab. Is there a way to get that while the write tab is first being generated…

to some extent, this should be possible for new articles too:

$status = getRow("show table status like 'textpattern'");
if (is_array($status)) {
	$next_ID = $status['Auto_increment'];
}

Offline

#22 2012-10-17 04:04:26

kr37
Member
From: Colorado
Registered: 2011-11-06
Posts: 28

Re: How do I add new elements (such as a pop-up form) in the Write tab?

Interesting, thanks for the tip!

Offline

Board footer

Powered by FluxBB