Advertisement:

Author Topic: How to create custom 'action'  (Read 209941 times)

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: How to create custom 'action'
« Reply #40 on: March 10, 2006, 11:21:39 AM »
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

Offline Delayed

  • Semi-Newbie
  • *
  • Posts: 21
PHP Include in actions
« Reply #41 on: March 10, 2006, 07:23:20 PM »
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

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: How to create custom 'action'
« Reply #42 on: March 10, 2006, 08:43:03 PM »
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(&#39;../tellafriend/inc.recommend.php&#39;);
     //Load the copyright and so on.
     
template_main_below();
}
if (isset(
$_REQUEST[&#39;action&#39;]) && $_REQUEST[&#39;action&#39;] == &#39;blah&#39;)
{
     
//Make use of SMF&#39;s layer system
     
$context[&#39;template_layers&#39;] = array();
     
$context[&#39;sub_template&#39;] = &#39;recommend&#39;;
}


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

Offline Delayed

  • Semi-Newbie
  • *
  • Posts: 21
Re: How to create custom 'action'
« Reply #43 on: March 10, 2006, 09:09:44 PM »
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.

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: How to create custom 'action'
« Reply #44 on: March 10, 2006, 09:16:57 PM »
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

Offline Delayed

  • Semi-Newbie
  • *
  • Posts: 21
Re: How to create custom 'action'
« Reply #45 on: March 10, 2006, 09:31:09 PM »
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 />
';
}

?>

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: How to create custom 'action'
« Reply #46 on: March 10, 2006, 09:44:01 PM »
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

Offline Delayed

  • Semi-Newbie
  • *
  • Posts: 21
Re: How to create custom 'action'
« Reply #47 on: March 10, 2006, 09:50:31 PM »
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.

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: How to create custom 'action'
« Reply #48 on: March 10, 2006, 10:19:43 PM »
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

Offline Delayed

  • Semi-Newbie
  • *
  • Posts: 21
Re: How to create custom 'action'
« Reply #49 on: March 10, 2006, 10:38:28 PM »
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?

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: How to create custom 'action'
« Reply #50 on: March 10, 2006, 10:44:14 PM »
No you do not need them.
Follow me on Twitter

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

Offline Delayed

  • Semi-Newbie
  • *
  • Posts: 21
Re: How to create custom 'action'
« Reply #51 on: March 11, 2006, 03:37:19 AM »
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.

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: How to create custom 'action'
« Reply #52 on: March 11, 2006, 02:12:21 PM »
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

Offline ArkServer

  • SMF Hero
  • ******
  • Posts: 1,831
  • My posts are my own
    • BlushyFace | A spoopy and creppy site
Re: How to create custom 'action'
« Reply #53 on: March 11, 2006, 07:14:24 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?

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: How to create custom 'action'
« Reply #54 on: March 11, 2006, 09:11:10 PM »
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

Offline onijin

  • Jr. Member
  • **
  • Posts: 132
  • Gender: Male
    • Forgotten Garden
Re: How to create custom 'action'
« Reply #55 on: April 04, 2006, 05:00:07 PM »
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?

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: How to create custom 'action'
« Reply #56 on: April 05, 2006, 11:34:25 AM »
You need to echo what you are going to add.  echo &#39;blah&#39;;.  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

Offline onijin

  • Jr. Member
  • **
  • Posts: 132
  • Gender: Male
    • Forgotten Garden
Re: How to create custom 'action'
« Reply #57 on: April 05, 2006, 05:38:12 PM »
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...  ^_^

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: How to create custom 'action'
« Reply #58 on: April 05, 2006, 06:59:27 PM »
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

Offline onijin

  • Jr. Member
  • **
  • Posts: 132
  • Gender: Male
    • Forgotten Garden
Re: How to create custom 'action'
« Reply #59 on: April 06, 2006, 09:37:14 AM »
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   ^_^