Not logged in. · Lost password · Register
Forum: General Discussion Plugins RSS
plugin:text - adding button to template
info on how to add a button that works with the text plugin
sidephase #1
Member for 2 months · 3 posts
Group memberships: Members
Show profile · Link to this post
Subject: plugin:text - adding button to template
hello :)

newb so I apologize if this has been asked before - for some reason I could not find it in the search tools. I'm using the text plugin and the instructions on the page have the following snippet:

To get a copy of rendered text in PHP (i.e. from a button or some other plugin) use:

global $ID;
$ID = $id; //necessary for correct metadata handling
$text = p_cached_output(wikiFN($id),'text');

my tpl_button code was as follows (originally within the tpl_button action block):

      case 'text':
        global $ID;
        $ID = $id; //necessary for correct metadata handling
        $text = p_cached_output(wikiFN($id),'text');
        echo html_btn('text',$ID,'e',array('do' => $text));
    return true;

I found the tpl_button code in main.php and added a new button action called text with the code above but no joy. Any ideas oh wiser members? :)

Thanks!
This post was edited on 2008-03-18, 10:26 by chi.
Edit reason: fixed broken link
sidephase #2
Member for 2 months · 3 posts
Group memberships: Members
Show profile · Link to this post
Tried this instead and at least saw a blank button but no action. Any ideas anyone?

       case 'text':
    /*    global $ID; */
        $ID = $id; //necessary for correct metadata handling
        $text = p_cached_output(wikiFN($id),'text');
        print html_btn('text',$ID,'e',array('do' => $text));
    return true;
ChrisS #3
Member since Sep 2006 · 82 posts
Group memberships: Members
Show profile · Link to this post
Don't worry about a tpl_button block or hacking DW code, you'll only run into problems when you need to update.  Simply add the following to your template at the point you want the button to appear.

<?php echo html_button('text',$ID,'e',array('do' => 'export_text'),'get','export this page as text'); ?>
sidephase #4
Member for 2 months · 3 posts
Group memberships: Members
Show profile · Link to this post
thanks for the code :)

had to make a change to it - html_button to html_btn - also label for the button doesn't show up. Version issue? I'm using the latest stable.
ChrisS #5
Member since Sep 2006 · 82 posts
Group memberships: Members
Show profile · Link to this post
It uses a language string of the form $lang['btn_<btn name>'].  Add a line somewhere in your template (before html_btn() call) to create that string.

e.g.
$lang['btn_text'] = 'Text';

if still nothing shows, try prefixing the above with a line containg "global $lang; ".
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please note the verification code from the picture into the text field next to it.
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 1.6.4, © 2003-7 by Yves Goergen
Current time: 2008-05-17, 06:31:23 (UTC +02:00)
WikiForumIRCBugsTranslate