Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: How do I add new elements (such as a pop-up form) in the Write tab?
kr37 wrote:
I don’t know in what way I could incorporate it into the write tab without deeply dissecting txp’s internals.
Simplest way is… a plugin. The core callback list gives you the names of plugin hook points. Raise a register_callback()
with the appropriate event/step (probably one of the pluggable_ui calls on the Write tab is your best bet) and then your named function will run whenever that point is hit.
smd_article_stats or any other admin side plugin will show you how it’s done.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#14 2012-04-17 20:54:45
- 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?
Wow. Thanks! Some years ago, under 4.0.4 I actually did hack all the way in to edit the write tab manually a bit. The callbacks look great!
Last edited by kr37 (2012-04-17 20:57:30)
Offline
Re: How do I add new elements (such as a pop-up form) in the Write tab?
If you need the article id in some JavaScript on the write page you can get it from the hidden input element.
var article_id = $('input[name="ID"]').val();
Last edited by MattD (2012-04-17 21:31:40)
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline
#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
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.
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
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