News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

How to create custom 'action'

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

Previous topic - Next topic

Stuart

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

onijin

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...

tX

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.

JayBachatero

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&amp;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&amp;subaction=test
Follow me on Twitter

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

Vinspire

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 ?

Stuart

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 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!

Rocket 442

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

unrelenting

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?

???

woden

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

unrelenting

#69
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.

Niteblade

#70
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 ?
affiliate blog

JayBachatero

Unless you add permission everyone should be able to look at it.
Follow me on Twitter

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

Niteblade

I installed the custom action mod .. what a wonderful mod it is. Link here.

Thanks!
affiliate blog

Captain_Morrigan

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

JayBachatero

#74
Yea you can.  This is what I did for a mod I was working on.

Code (source file) Select

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';
}


Code (template file) Select

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'),
Follow me on Twitter

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

Captain_Morrigan

Awesome thank you so much! You rock!

Johno69

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.

JayBachatero

Add that to the source file you made.
Follow me on Twitter

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

Johno69

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.

JayBachatero

You need another file on Sources dir.  Like the example shows.
Follow me on Twitter

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

Advertisement: