How to create custom 'action'

Started by Owdy, January 09, 2005, 05:01:30 PM

Previous topic - Next topic

JayBachatero

You can put an include with the full path to the file.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Delayed

I have a couple of actions working but I can't get the PHP include to work.  I have it working in another part of my site but for some reason when I do the include all I get is a blank file  I have tried just about everything that I can think of. 

I have already tried this with the PHP tags, without, etc.  What am I doing wrong.

<?php include("../tellafriend/inc.recommend.php");?>

Can anyone point me in the right direction.

Thanks

JayBachatero

If you just want to include that file use this.


function template_recommend()
{
     
//Load the main_above template.  This is the header part
     
template_main_above();
     
//Load the file needed to be loaded
     
include('../tellafriend/inc.recommend.php');
     
//Load the copyright and so on.
     
template_main_below();
}
if (isset(
$_REQUEST['action']) && $_REQUEST['action'] == 'blah')
{
     
//Make use of SMF's layer system
     
$context['template_layers'] = array();
     
$context['sub_template'] = 'recommend';
}


You can try using that.  Just add it at the end of index.template.php for your theme.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Delayed

Okay I put that at the end of my index.template.php file.  So what do I put in my tellafriend.template.php
that I have in my theme

if it is this then

<?php include("../tellafriend/inc.recommend.php");?>

it still doesn't work.

I must not be getting something.

JayBachatero

What do you have in the tellafriend.template.php file?  Do you have anything else in there or just the include?
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Delayed

Here is what I have.  I replaced the My Cool Downloads in the example text with my include.

<?php

function template_main()
{
global $context, $settings, $options, $txt, $scripturl;

echo '


<table width="100%" border="0" cellspacing="0" cellpadding="3" >
<tr>
<td>', theme_linktree(), '</td>
</tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="4" align="center" class="tborder">
<tr class="titlebg">
<td align="center" >Download area</td>
</tr><tr>
<td class="windowbg">';

echo '<table border="0" cellpadding="0" cellspacing="3" width="100%">
         <tr>
           <td width="100%" valign="top">
      <?php include("../tellafriend/inc.recommend.php");?>
   </td></tr></table>';
echo '
</td>
</tr>
</table><br /><br />
';
}

?>

JayBachatero

First thing.  You have the statement enclosed in <?php tags inside <?php tags.
Second the include is inside an echo. 

The method I showed you would do just what you want.  No need for tellafriend.template.php
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Delayed

So after my index.template file is edited with function template_recommend() like you said then what do I need to do so that my script is called so that it looks like the other actions.

JayBachatero

It should work just that way.  Give it a try.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Delayed

I have edited the index.template.php for my default theme like you said to above.

It still isn't working.

Okay you said that I didn't need the  tellafriend.template.php so I deleted it and now it is loading the page but it says " Unable to load the 'tellafriend' template."  With the  tellafriend.template.php there it doesn't work either.

Do I still use the edited index.php and created tellafriend.php like in the first post?

JayBachatero

Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Delayed

It still doesn't work.  I think that I am going to give up adding this PHP file as an action.  I am at my wits end on this thing.  I have tried just about everything. 

I got some other stuff to work as you can see in my other posts such as other actions and tab buttons but this include is driving me nuts.

I guess it really isn't a big deal just wanted to give it more room for other options.  I may try again in the morning but who knows.

JayBachatero

All you really need to do is add this to the index.template.php  Right before ?>.  You do not need to create a template file, edit index.php, or create a source file. 
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

ArkServer

Quote from: Stuart on February 04, 2006, 05:32:07 PM
I actually managed to create 2 custom actions and you can see them on my website:

http://www.astmaforum.nl/index.php?action=links

http://www.astmaforum.nl/index.php?action=faq

I'm quite proud I was able to create these pages. But I couldn't have done it without the clear and easy instructions which were given in this topic. Thanks ever so much for that  :D


How did you made the faq page? mod?

JayBachatero

Ark it's just a page with FAQ's.  It's not a mod.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

onijin

Well, I tried making my own FAQ page, but I think I'm screwing up somewhere.

When I put the "download" code given up there, it works fine.

I try to replace that with what I want; text, tables, bookmarks, and bookmark links, I get bombarded with "Template Parse Error-parse error, unexpected T_STRING, expecting ',' or ';'".  It's inside an echo, and at the end of all this, there is " '; "  I don't see any flaws and all my tags are properly closed.  Am I doing something wrong?  ^_^

Perhaps I can't put bookmarks?

JayBachatero

You need to echo what you are going to add.  echo 'blah';.  Apostrophes (') must be escaped with \ like PC\'s
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

onijin

it is in an echo.

I tried just adding the first 5 lines (all bookmark links) and I still got the parse error.  =/

Perhaps I should just do plain text.  Gawd that's boring...  =/


Well... I'll keep at it and try to figure it out...  ^_^

JayBachatero

Can you please post the code you are trying to put in?
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

onijin

You gotta be kidding...

In front page, i used the search string ' and searched for any apostophies, and I found the culprit!

Just one apost. that wasn't \[/color]...

I am dumb!  ^_^

Thanks for the support, Jay   ^_^

Advertisement: