Notice:
This tip has been in some way ported over to be a modification package located on the SMF modsite (http://mods.simplemachines.org/index.php?mod=331). Please note, the mod package may not do the exact same function and may not even use any of the code originally written for the tip, but should still hold the same basic functionality of the tip posted here. With the mod package for this tip, you can now let the SMF package manager make the code changes for you without you having to look at the code and edit it manually.
For documentation on using the SMF package manager, view this document (http://docs.simplemachines.org/index.php?board=49.0).
To download the modification package, please click here (http://mods.simplemachines.org/index.php?mod=331).
If you need your custom action, here's howto. Lets say you want own dowload area.
index.php find:
'activate' => array('Register.php', 'Activate'),
ad after:
'downloads' => array('Downloads.php', 'Downloads'),
Then create 'Downloads.php' like this:
<?php
if (!defined('SMF'))
die('Hacking attempt...');
function Downloads() {
global $context;
$context['page_title'] = 'My Actions title!';
// This is gonna be needed...
loadTemplate('Downloads');
}
?>
Put that Downloads.php to /Sources/
Then, create to Themes/default/Downloads.template.php, something like this:
<?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">
MY cool downloads!!!!
</td></tr></table>';
echo '
</td>
</tr>
</table><br /><br />
';
}
?>
Then just do this http://www.example.com/smf/index.php?action=downloads
You can change that 'Downloads' and modify that theme file to fit your needs.
DEMO: http://www.halko.net/smf/index.php?action=test
Enjoy :)
Also read this, which is related but tied to themes:
http://www.simplemachines.org/community/index.php?action=dlattach;topic=7703.0;id=3102
-[Unknown]
is there an example of this?
For the themes one, there is in Unknowns guide. I've begun integrating the vCard option that was in IPB to my IPB theme using action wrapping :P
Quote from: Owdy on January 09, 2005, 05:01:30 PM
Then create 'Downloads.php' like this:
<?php
if (!defined('SMF'))
die('Hacking attempt...');
function Downloads() {
// This is gonna be needed...
loadTemplate('Downloads');
}
?>
Put that Downloads.php to /Sources/
I don't think this will show a page title (some one stuff a sock in my mouth if I am wrong ;)) to make the new action have a page title you would need to do this:
<?php
if (!defined('SMF'))
die('Hacking attempt...');
function Downloads() {
global $context;
$context['page_title'] = 'My Actions title!';
// This is gonna be needed...
loadTemplate('Downloads');
}
?>
True. Thanks J! :) I changed that to first post.
Added demo.
Owdy,
Thanks for the excellent 'How to'
I can see that I will be putting this in to practice a lot.
A related question
I've got a game that runs of the userbase of SMF, and does this via the SSI. How can I show that a user is at the game page when you get the Users online list, instead f it showing unkown action?
Ad this to Modifications.english.php
$txt['whoall_customaction'] = 'Do something in <a href="' . $scripturl . '?action=customaction">custom area</a>.';
nice idea, im thinkin of using it for a karma log, but im stuck on a small problem
ive a few custom actions done, one is action=karmalog to show who Applauds/Smites but i cant get it to work right, could someone help me out on the script? im new to php..
this is the code i wanna use for the template but its wrong somewhere, any ideas?
<?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">Karma Log</td>
</tr><tr>
<td class="windowbg">';
echo '<table border="0" cellpadding="0" cellspacing="3" width="100%">
<tr>
<?php
include ('SSI.php');
global $db_prefix;
$karma_result = db_query("
SELECT lk.ID_TARGET, lk.ID_EXECUTOR, lk.logTime, lk.action, memt.realName AS targetName, meme.realName AS executorName, meme.ID_MEMBER as executorID, memt.ID_MEMBER as targetID
FROM {$db_prefix}log_karma AS lk, {$db_prefix}members AS memt, {$db_prefix}members AS meme
WHERE memt.ID_MEMBER = lk.ID_TARGET
AND meme.ID_MEMBER = lk.ID_EXECUTOR
ORDER BY logTime DESC
LIMIT 100", __FILE__, __LINE__);
$return = array();
while ($row_karmas = mysql_fetch_assoc($karma_result))
$return[] = array(
'executor' => $row_karmas['executorName'],
'executorID' => $row_karmas['executorID'],
'target' => $row_karmas['targetName'],
'targetID' => $row_karmas['targetID'],
'action' => $row_karmas['action'] == 1 ? '<font color=green>Applauds' : '<font color=#CC0000>Smites',
'time' => timeformat($row_karmas['logTime'])
);
mysql_free_result($karma_result);
foreach ($return as $data)
echo '<a href=', $scripturl, '?action=profile;u=', $data['executorID'], '><font color=#000000>', $data['executor'], '</font></a> ', $data['action'], ' <a href=', $scripturl, '?action=profile;u=', $data['targetID'], '>', $data['target'], '</a></font> ', $data['time'], '<br />';
unset($return);
?>
<td width="100%" valign="top">
</td></tr></table>';
echo '
</td>
</tr>
</table><br /><br />
';
}
?>
I'd use:
<?php
function template_main()
{
global $context, $settings, $options, $txt, $scripturl, $boarddir, $db_prefix;
include($boarddir . '/SSI.php');
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">Karma Log</td>
</tr>
<tr>
<td class="windowbg">
<table border="0" cellpadding="0" cellspacing="3" width="100%">
<tr>';
$karma_result = db_query("
SELECT lk.ID_TARGET, lk.ID_EXECUTOR, lk.logTime, lk.action, memt.realName AS targetName, meme.realName AS executorName, meme.ID_MEMBER as executorID, memt.ID_MEMBER as targetID
FROM {$db_prefix}log_karma AS lk, {$db_prefix}members AS memt, {$db_prefix}members AS meme
WHERE memt.ID_MEMBER = lk.ID_TARGET
AND meme.ID_MEMBER = lk.ID_EXECUTOR
ORDER BY logTime DESC
LIMIT 100", __FILE__, __LINE__);
$return = array();
while ($row_karmas = mysql_fetch_assoc($karma_result))
{
$return[] = array(
'executor' => $row_karmas['executorName'],
'executorID' => $row_karmas['executorID'],
'target' => $row_karmas['targetName'],
'targetID' => $row_karmas['targetID'],
'action' => $row_karmas['action'] == 1 ? '<font color=green>Applauds' : '<font color=#CC0000>Smites',
'time' => timeformat($row_karmas['logTime'])
);
}
mysql_free_result($karma_result);
echo '
<td width="100%" valign="top">';
foreach ($return as $data)
echo '<a href=', $scripturl, '?action=profile;u=', $data['executorID'], '><font color=#000000>', $data['executor'], '</font></a> ', $data['action'], ' <a href=', $scripturl, '?action=profile;u=', $data['targetID'], '>', $data['target'], '</a></font> ', $data['time'], '<br />';
echo '
</td>
</tr>
</table>';
echo '
</td>
</tr>
</table><br /><br />';
}
?>
[Edit: fixed a typo.]
Thank You Kirby Much appreciated. :D
No problem :)
how can i reflect mypage to the tree link?
i've tried adding
$context['linktree'][] = array(
'url' => $scripturl . '?action=mypage',
'name' => $txt['mypage']
);
after the page title but i only get a separator..
Is $txt['mypage'] defined? Did you add $txt to the global line?
-[Unknown]
ah.. spot on! thanks :D
Quote from: Owdy on January 09, 2005, 05:01:30 PM
If you need your custom action, here's howto. Lets say you want own dowload area.
index.php find:
'activate' => array('Register.php', 'Activate'),
ad after:
'downloads' => array('Downloads.php', 'Downloads'),
Then create 'Downloads.php' like this:
<?php
if (!defined('SMF'))
die('Hacking attempt...');
function Downloads() {
global $context;
$context['page_title'] = 'My Actions title!';
// This is gonna be needed...
loadTemplate('Downloads');
}
?>
Put that Downloads.php to /Sources/
Then, create to Themes/default/ 'Downloads.template.php, something like this:
<?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">
MY cool downloads!!!!
</td></tr></table>';
echo '
</td>
</tr>
</table><br /><br />
';
}
?>
Then just do this http://www.example.com/smf/index.php?action=downloads
You can change that 'Downloads' and modify that theme file to fit your needs.
DEMO: http://www.halko.net/smf/index.php?action=test
Enjoy :)
That's great, I got it up and running on SMF 1.1 Beta 3, but where shall I put the files to be downloaded in???
Its just an example. You can put them anywhere yoy want.
ok, these are my current files:
Downloads.template.php
<?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">
MY cool downloads!!!!
</td></tr></table>';
echo '
</td>
</tr>
</table><br /><br />
';
}
?>
Sources/Downloads.php
<?php
global $context;
if (!defined('SMF'))
die('Hacking attempt...');
Function Downloads()
{
global $boardurl,$txt, $scripturl, $db_prefix;
global $ID_MEMBER;
global $context, $user_info, $db_prefix;
LoadTemplate('Downloads');
Loadlanguage('Downloads');
$context['page_title'] = $txt['downloads_1'];
$context['linktree'][] = array(
'url' => $scripturl . '?action=downloads',
'name' => $txt['downloads_1']
);
isAllowedTo('view_downloads');
}
?>
What should I change if the downloadable files are placed in a folder named "downloads" in the root directory...???
P.S: I'm not using the default theme...
Owdy: Have you got that theme on your SMF forum avaliable?
If you saw that brown theme, its for ubuntu finland site: http://forum.ubuntu-fi.org/
Have you got it as in, packaged? or will I have to create it myself?
No, that theme is not shared. Its for Ubuntu site only.
Oh... Ok! :)
Edit: I'm following your instuctions, but how do I make the id= part:
http://localhost/LbaX/forum/downloads.php?id=04
instead of:
http://localhost/LbaX/forum/downloads.php?04
???
Quote from: Owdy on January 09, 2005, 05:01:30 PM
If you need your custom action, here's howto. Lets say you want own dowload area. /../
Thnx Owdy. I got it to work.
But now another question. I want that script to open inside the same page, where from I called it out. Like shoutbox. Example; if I include shoutbox to main template and then shout, it does not open page only with shoutbox, but with (within) page where it was. I tryed to look into shout.php and shout.template.php, but I did'nt get, how it works. How it remembers the page, where from it was called out.
Hopefully I explained my problem enough clear.
ps. okidoki.. i made picture about I want:
(http://kristus.pri.ee/My_Images/board1.GIF)
I have used your instructions sucessfully and I'm now very happy with my result.
Just 1 point to improve my 'static' page further: How can I get so on the Who's Online page it says 'Viewing downloads' or something rather than 'Unknown Action' ?
Quote from: Owdy on February 01, 2005, 04:26:42 PM
Ad this to Modifications.english.php
$txt['whoall_customaction'] = 'Do something in <a href="' . $scripturl . '?action=customaction">custom area</a>.';
Quote from: JayBachatero on January 18, 2006, 08:13:00 PM
Quote from: Owdy on February 01, 2005, 04:26:42 PM
Ad this to Modifications.english.php
$txt['whoall_customaction'] = 'Do something in <a href="' . $scripturl . '?action=customaction">custom area</a>.';
thanks, I must of missed it by mistake :P
Erm, this may be going off topic too much but could someone tell me if/how I can also show the user is viewing a page that isn't a forum page, it's a seperate page.php not using ?action= anything, but it is only showing them the content if they're logged in. Or pointing me to the right direction I'd be grateful for as searching hasn't helped.
Search for who action (http://www.simplemachines.org/community/index.php?action=search2;search=who%20action) and you will see a few posts about this.
Edit :-[
Didn't realise the templates were case sensitive :-[
I figured it out and my own integrated FAQ page is a fact from now on :D
Stuart, i moved your post because its another issue http://www.simplemachines.org/community/index.php?topic=66969.0
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 would i do Sub-Actions? I can't seem to figure it out.. and profile.php in sources is to confusing to try to figure out how it is doing it.
does this automatically create a button on the 1.1rc2 forum index? and can it be set by permissions?
or does this even work in 1.1 rc2 lol.
It dosnt create any buttons.
ok well, im new to the smf scene here (sorry :P ) so if you could teach me how to add a button at the top for my new custom action. But i only want it to show if they are logged in (if possible)
How to add tabs to Core (NDT)? (http://www.simplemachines.org/community/index.php?topic=63203.0)
if the file is download.htm instead of download.phpthen what we must do?
What if I want to include a PHP file in the example "download.template.php" file? Can I use an include method or do I need to paste the entire PHP file?
It is a tell a friend PHP script that I want to put in the action.
Thanks
You can put an include with the full path to the file.
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
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.
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.
What do you have in the tellafriend.template.php file? Do you have anything else in there or just the include?
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 />
';
}
?>
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
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.
It should work just that way. Give it a try.
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?
No you do not need them.
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.
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.
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?
Ark it's just a page with FAQ's. It's not a mod.
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?
You need to echo what you are going to add. echo 'blah';. Apostrophes (') must be escaped with \ like PC\'s
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... ^_^
Can you please post the code you are trying to put in?
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 ^_^
Quote from: ArkServer on March 11, 2006, 07:14:24 PM
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?
Just using HTML and then create the custom action :D
It's quite simple actually, as long as you be aware of the use of 'apostrophes ;D
Quote from: Stuart on April 08, 2006, 07:01:15 PM
Just using HTML and then create the custom action :D
It's quite simple actually, as long as you be aware of the use of 'apostrophes ;D
damn apostrophes...
how can you make pages witin the custom action, like another meber asked "sub custom actions" which i think he was talking about what i am. for example.
http://www.simplemachines.org/community/index.php?action=help
http://www.simplemachines.org/community/index.php?action=help;page=profile
http://www.simplemachines.org/community/index.php?action=help;page=post
How would you get the profile and post pages within the custom action? I am creating a downlaod page and tab(got the auctum action and tab working, jsut need to finsih the page) and would like to do a article page, but i dont want to have a seperate custom action page for each one, i would like to just be able to do something suuch as
http://www.example.org/forum/index.php?action=articles just article page whcih links to the articles
http://www.example.org/forum/index.php?action=articles;page=article1 one of the articles
http://www.example.org/forum/index.php?action=articles;page=article2 another article, ext ext. Thanks.
You can do something like
<?php
echo 'This is a test for actions.</br>';
echo '1. <a href="?action=1">Regular action</a><br />';
echo '2. <a href="?action=1&subaction=2">Subaction</a><br />';
if (isset($_REQUEST['action']) && $_REQUEST['action'] == '1')
{
echo 'This ia a regular action<br />';
if (isset($_REQUEST['subaction']) && $_REQUEST['subaction'] == '2')
{
echo 'This is a subaction inside an action<br />';
}
}
?>
http://www.kevmundial.com/subactions.php
You do that inside the function and you link to it like index.php?action=hello&subaction=test
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
Very nice work there Stuart. Can tell me which instruction should i follow to do what you did ?
Quote from: Vinspire on May 10, 2006, 06:16:37 AM
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
Very nice work there Stuart. Can tell me which instruction should i follow to do what you did ?
Thanks :D Basically you can just do whatever is said in THIS (http://www.simplemachines.org/community/index.php?topic=23864.msg189057#msg189057) post :)
If you cannot figure out how to do it I can give you some help providing you already know what you want. I guess you'll just have to try things out. You can actually create a HTML page and make that into a custom action as long as you're aware that you shouldn't use apostrophes as that might give an error!
I tried this, and got a couple errors, anyone know what they could be?
Notice: Undefined variable: modSettings in /home/olds442/public_html/smfforum/Sources/Load.php(1040) : eval()'d code on line 196
An Error Has Occurred!
2: smf_main(): Unable to access /home/olds442/public_html/smfforum/Sources/Downloads.php
File: /home/olds442/public_html/smfforum/index.php
Line: 330
I tried this and it works like a charm. Thanks.
Now I want to make the download action page only viewable by a certain permission group that I made. I want to set certain people up on a secondary membership group so that they can see the new tab and everyone not in that group can't. Can anyone tell me how I can do this.
I assumed I could just add a line in the admin-general permissions area but I can't figure out what file to edit to add the line. I found the ManagePermissions.english.php file that I would add the txt[] line to.
Is there a different way of doing this?
???
I use this:
if (in_array(13, $GLOBALS['user_info']['groups']))
{ echo ' insert button code here ';}
else
{ echo '';}
in this case the group number was 13
Quote from: woden on May 20, 2006, 11:48:36 PM
I use this:
if (in_array(13, $GLOBALS['user_info']['groups']))
{ echo ' insert button code here ';}
else
{ echo '';}
in this case the group number was 13
That worked perfectly, except that it doesn't keep anyone out if they have a simple link to the page. If I log in as someone without access I don't see the link on my button bar but if I paste a link in my address bar I get right in. I want to guarantee that none of my users share the link if possible.
i'm attempting to create a custom action that calls a php file inside an iframe. (similar to but different than the flashchat integration..) i want guests, spiders, etc. to be able to access the function. are the instructions here, or must i do something different ?
Unless you add permission everyone should be able to look at it.
I installed the custom action mod .. what a wonderful mod it is. Link here (http://www.simplemachines.org/community/index.php?topic=86793.msg600036#msg600036).
Thanks!
Is there a way to escape the default headers and footers for a custom action?
This is why I ask:
I am trying to create an awards mod that pops up in a tiny window with the awards in it. I want it to escape the headers because when you click on it it should just show the table that has the awards in it.
Anyone that can help I would appreciate it.
You can see what I mean by going here:
http://test.enchantinge.com
Yea you can. This is what I did for a mod I was working on.
function play_popup()
{
global $txt, $helptxt, $context;
// Load the admin help language file and template.
loadLanguage('Media');
loadTemplate('Media');
// Set the page title to something relevant.
$context['page_title'] = $context['forum_name'] . ' - ' . $txt['media_title'];
// Don't show any template layers, just the popup sub template.
$context['template_layers'] = array();
$context['sub_template'] = 'popup';
}
function template_popup()
{
global $context, $settings, $options, $txt, $scripturl, $row;
// Since this is a popup of its own we need to start the html, etc.
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=' ,$context['character_set'], '" />
<title>' ,$context['page_title'], '</title>';
</head>
<body>
STUFF GOES HERE
</body>
</html>';
}
In index.php I added 'play' => array('Media.php', 'play_popup'),
Awesome thank you so much! You rock!
Quote from: iwyen on June 18, 2005, 09:47:31 AM
how can i reflect mypage to the tree link?
i've tried adding
$context['linktree'][] = array(
'url' => $scripturl . '?action=mypage',
'name' => $txt['mypage']
);
after the page title but i only get a separator..
Quote from: [Unknown] on June 18, 2005, 09:48:40 AM
Is $txt['mypage'] defined? Did you add $txt to the global line?
-[Unknown]
Can you explain where this goes please ? I'd like the tree on my custom page too.
Add that to the source file you made.
Sorry not exactly sure where...
<?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" >Photo area</td>
</tr><tr>
<td class="windowbg">';
echo '<table border="0" cellpadding="0" cellspacing="3" width="100%">
<tr>
<td width="100%" valign="top"><br>
<center>Content Here</center><br>
</td></tr></table>';
echo '
</td>
</tr>
</table><br /><br />
';
}
?>
That is my current code.
You need another file on Sources dir. Like the example shows.
Yes I have... here's the code:
<?php
if (!defined('SMF'))
die('Hacking attempt...');
function Photos() {
global $context;
$context['page_title'] = 'Photos';
// This is gonna be needed...
loadTemplate('Photos');
}
?>
Still not exactly sure where to put the tree stuff.
<?php
if (!defined('SMF'))
die('Hacking attempt...');
function Photos()
{
global $context, $txt;
$context['page_title'] = 'Photos';
$context['linktree'][] = array(
'url' => $scripturl . '?action=mypage',
'name' => $txt['mypage']
);
// This is gonna be needed...
loadTemplate('Photos');
}
?>
Many Thanks.
i'm using the helios theme and i'd like the top bar (bg) to show also behind the tree, any idea how to so this.
Not sure sure about that. Look into the index.template.php file.
Hi I've installed a page using this code but I run into some minor errors.
i've tried adding a linkbutton on the home of my site, in the same style.
Now that works I can call the page as well, but when I go inside the admin panel and view the forum error log I get a load of errors:
http://www.ww/www/index.php
8: Undefined index: linkbuttons
File: /home/pixellus/public_html/PI/Themes/default/languages/Shop.english.php (eval?)
Line: 473
http://www.www/www/index.php?action=linkbuttons
8: Undefined index: linkbuttons
File: /home/pixellus/public_html/PI/Themes/default/languages/Shop.english.php (eval?)
Line: 473
Annyone know how I can fix this?
The code for the button I used is this 1 I think that is the error actually:
//linkbuttons
echo "<a href='{$scripturl}?action=linkbuttons'>", ($settings['use_image_buttons'] ? "<img src='{$settings['images_url']}/{$context['user']['language']}/linkbuttons.gif' alt='{$txt['linkbuttons']}' style='margin: 2px 0;' border='0' />" : $txt['linkbuttons']), "</a>{$context['menu_separator']}";
//end linkbuttons
Thanks so much
Hello,
I followed all the instructions for the first post in the topic and created my Downloads.php and Downloads.template.php.
However, when I try to use downloads as an action, I get the error "Unable to load the 'Downloads' template."
I have tried a variety of changes to the code with no success.
Does anyone recognise this error and it's most likely causes.
thanks
Peter
Hi, I worked through the problem with not able to load the template.
I added loads of debugging output in Load.php and that highlighted that the path in my default themes setting was wrong!!!
It all works fine now.
thanks
Peter B
I just spent hours (well I made some mistakes) to find out how to implement subactions so I thought it might be helpful for others who where searching for the same information...
Downloads.php:
<?php
if (!defined('SMF'))
die('Hacking attempt...');
function Downloads()
{
//Load the main template file
loadtemplate('Downloads');
//Downloads Actions
$subActions = array(
'subdownloads' => 'SubDownloads',
);
// Follow the sa or just go to main function
@$sa = $_GET['sa'];
if (!empty($subActions[$sa]))
$subActions[$sa]();
else
main();
}
function Main() {
global $context;
$context['page_title'] = 'My Actions title!';
}
function SubDownloads(){
global $context;
$context['page_title'] = 'My SubDownloads!';
// This is gonna be needed...
$context['sub_template'] = 'SubDownloads';
}
?>
Downloads.template.php:
<?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">
MY cool downloads!!!!<br>
<a href="', $scripturl, '?action=downloads;sa=subdownloads">SubDownloads</a>
</td></tr></table>';
echo '
</td>
</tr>
</table><br /><br />
';
}
function template_SubDownloads()
{
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" >Sub Downloads area</td>
</tr><tr>
<td class="windowbg">';
echo '<table border="0" cellpadding="0" cellspacing="3" width="100%">
<tr>
<td width="100%" valign="top">
This is the SubDownloads page!!!!
</td></tr></table>';
echo '
</td>
</tr>
</table><br /><br />
';
}
?>
with this small example it functions like a charm, unfortunatly I didn't get it into my mod I am working on so far :-[ ... but at least I know now I am on the right track!! :)
Maybe a moderator might add thisto first post, or a link in the first post to this post as a hint... oh and maybe this moderator might go through the code first to optimize it ;D
Anyone who can help me with this : http://www.simplemachines.org/community/index.php?topic=193302.0 ???
Quote from: Owdy on January 09, 2005, 05:01:30 PM
index.php find:
'activate' => array('Register.php', 'Activate'),
ad after:
'downloads' => array('Downloads.php', 'Downloads'),
I can't find anything like that.
That's all that shows up on my index.php:
<?php
// Try to handle it with the upper level index.php. (it should know what to do.)
if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
include (dirname(dirname(__FILE__)) . '/index.php');
else
exit;
?>
That's not the correct index.php file. Open the one in the root directory of your forum.
Also, are you aware there is now a mod that you can use to create custom actions?
Thanks!
Everything's working now :]
Yep, but we're trying to make the board mod free.
Thanks again :)
A little help with this ?
http://www.simplemachines.org/community/index.php?topic=63203.msg1470635#msg1470635
I get page that I created above header, and below that header is Can't load main ??
Thank you in advance.
how can create the wap/wap2/imode version for action=downloads , from example? :-> action=downloads;imode !
??? ??? Please help !! any1 ! ???? how can create the template for that example "action=downloads" in wireless.template.php??
Will the custom action mod work on 1.1.5
Yes it works, i've tried it...
Hi,
Using the guide posted above (adding the action to the index.php and stuff) I created a custom action.
I don't really understand how to pass info between the action.php and action.template.php so initially I just dumped all my code into action.template.php however when I want to customize the page title I realized it can only be done in the source file, not the template one.
So my question is.. what goes into the source file usually? what goes in the template file usually? I have a few queries and show some tables based on them, how would I pass info from the query done in the source file (where based on the query results I can set the page title) to the template file?
Also, is there a way to set the page title from the template file?
Any help is much appreciated
An old thread I know, but still useful.
My question is the same as the one above. What would the mod makers advise goes in each file ? And also how to pass data between them ?
Thanks for any help.
Quote from: MrMorph on July 13, 2009, 02:17:01 PM
An old thread I know, but still useful.
My question is the same as the one above. What would the mod makers advise goes in each file ? And also how to pass data between them ?
Thanks for any help.
Maybe you should try this Mod
http://custom.simplemachines.org/mods/index.php?mod=331
Nice clean tutorial.
But I have an error somehow :|
I've created 2 pages, each with the exact same code. The first page works fine, but in the secpnd page I always get the error Unable to load 'main' template
I've been searching around the forums and tried many solutions, but none fixed the error.
Anyone who can help me out? I can post the files if needed.
Thanks in advance,
Tyilanmenyn
Did you create a template file for your new action? Did you also call loadTemplate with the template's file name?
E.g. Newaction.template.php needs a matching loadTemplate('Newaction') call somewhere in the action's code.
I don't know why but only the header and menu appears nothing else :/
Hey,
Panels and code blocks don't work while I'm using that mod that you linked, anyone know some reason why? I've tried all the default blocks as well as my regular blocks. The action is set to HTML.
Secondly, I followed the tutorial to the letter but all it does is loop me back to my forum. I'm using my own custom theme, is there something specific I have to do along with that tutorial?
arantor:
QuoteDid you create a template file for your new action? Did you also call loadTemplate with the template's file name?
E.g. Newaction.template.php needs a matching loadTemplate('Newaction') call somewhere in the action's code.
but you only load once if the action has subactions? and it's called in function Main() ....?
i have a page with the main() function, my_function(), and some functions relating to subactions. then on the template page it calls the template_function of each one...
the template_main() comes in fine, but the others (maybe because they are php-coded, not html) come in above the automatic background (smf's header footer etc, which must be auto loaded as we are coming from index.php?action=xxx;sa=yyy)
any idea how i would get the subaction stuff to sit within the auto templates, and not above?
thanks
how to have smf 2.0 rc4 redirect the poster back to the last post ?
i have lots of questions to have it in there but dont know how to..... thanks