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

Main Menu

Custom Action Mod

Started by Norv, May 09, 2006, 08:35:29 PM

Previous topic - Next topic


On your forum, go to Admin -> Package Manager -> Browse Packages

Once there, scroll to the bottom, click the "advanced" link, change the version to an earlier version, e.g. SMF 2.0, or SMF 2.0 RC5. Click the "Apply" button and try reinstalling the mod.  This should work.  Make sure when you are done you revert your settings back to the default.
SMF 2.0.1
SimplePortal 2.3.3


Thanks for the reply but I have already tried that option. It doesn't appear as though this mod is configured to work with the Package Manager?


emulate SMF 2.0 RC4 - see if that works for you.  Or you could open up the zip file for the package, then edit package-info.xml, find all instances of this:

install for="2.0 RC4 - 2.0.99"

and replace it with:

install for="2.0.1"

Then zip it all back up and try again, with your emulator reverted back to default
SMF 2.0.1
SimplePortal 2.3.3


Okay cloksin, I will give it a try. Thanks!

EDIT: That did it. Thanks again cloksin.


This mod is cool. I have a BBC action working. Now what do I have to do to get a PHP action working?

The PHP code I have is good. I coded a simple action and template by hand and it tests good. But using the same code in the Custom Action Mod doesn't work. I'm sure its something simple with the PHP wrapper code maybe? I just haven't found any good instructions or samples to follow.


EDIT:  Okay, got it working. Have to leave out the SMF specific code.


Making Link Tree work with Custom Action Mod.

I thought about setting this up by extending this mod but I tested it out in the mod's code window for a new action and it works.
Maybe I should find a need before trying to fulfill it but since I had a bit of a trial-and-error session myself, here it is.

In the Source File Code window:

$context['linktree'][] = array(
'url' => $scripturl. '?action=test_php',
'name' => 'TestPHP',

    the action=youraction should be easy enough to understand;
    the name 'TestPHP' can be anything you want it to be.

This also works with subactions. You will need to copy the above code into your Source File Code window and another version of it for the sub-action.
See the code below:

$context['linktree'][] = array(
'url' => $scripturl. '?action=test_php',
'name' => 'TestPHP',

$context['linktree'][] = array(
'url' => $scripturl. '?action=test_php;sa=subtestphp',
'name' => 'SubTestPHP',

An anchor link to the sub-action in the Template Code section of your custom action:

echo '
    <a href="index.php?action=test_php;sa=subtestphp">Go to Sub-action test.</a>

Hopefully this helps someone. I had to go through a long process of hand-crafting a custom action to understand how all of the parts worked.
Custom Actions with Link Tree. Cool way to go.


There is some error in package, when I try to download it through 'Package Manager' it throws out error:

But when I repack it to *.zip and download it then it works.
Polskie wsparcie SMF na

the simplest solution is most likely the right one

Jeff B

I'm wondering if anyone can help me figure this out.  I am trying to use the custom action function to add some calculators to my site.  In the head area, I had the script source, and in the body, I add the code to follow. What happens after I save it, is that part of the code, actually becomes part of the custom actions page, and I can not modify, or delete the custom action.  The page works, but it breaks the mod.  I have to go into PHPMyAdmin and delete the custom action from the custom actions table.

I tried it without putting the script in the head, and it does the very same thing.  I'll attach the code that breaks the mod, and also a screen shot for you to see what is happening.  I'm guessing this could be considered a bug. What to look for in the screenshot is under the post box, part of the form becomes part of the mod page, rendering it inoperable.

        <form name="spec">
            <input type="text" name="depth" size="2"> Thickness in inches
            <input type="text" name="width" size="2"> Width in inches
            <input type="text" name="length" size="2"> Length in feet<br>

            <input type="text" name="piece" size="2"> Number of pieces
            <input type="text" name="Bpackage" value="1" size="2"> Number of packages*
            <input type="text" name="cost" value size="4"> Price per/Mbf<br>
          <p align="center"><font face="Arial" size="2"><small>*If package number
            is not applicable, leave number at 1</small><br>

            <div align="center"><font face="Arial" size="2">
              <input type="button" name="answer" value="Calculate and add lumber to total" onClick="updateAnswer();">
              Lumber entered list:<br>
              <textarea name="list" cols="50" rows="2"></textarea>

              Total board footage:
              <input type="text" name="answerTotal" value="0" size="10">
              Total Price $
              <input type="text" name="price" value="0" size="5">
              <input type="button" name="Confirmreset" value="Reset" onClick="if( confirm('Are you sure you want to reset?') ) {resetFormData(); }">



I suspect that the mod incorrectly interprets the </textarea> tag as the end of its own <textarea> where you enter your code rather than the end of the <textarea> in your code.
Try temporarily removing <textarea name="list" cols="50" rows="2"></textarea> from the code and see if it helps.
You could also try replacing </textarea> with &lt;/textarea&gt;

Jeff B

Yup, that is the culprit, however &lt;/textarea&gt; does not seem to be the answer. It renders the calc inoperable.

The custom action page performs just fine once created, its just the only way to edit or delete it is within phpmyadmin.  :-\


The mod adds the line below to Themes/default/Admin.template.php, (line 2323 in my version).
<textarea name="body" rows="20" cols="60">', $context['action']['body'], '</textarea>

If that line is replaced with
<textarea name="body" rows="20" cols="60">', htmlspecialchars($context['action']['body']), '</textarea>
it seems to work.

Jeff B

Excellent!  Seems to work perfectly. Thank you very much.  :)


SMF 2.0.1, Custom Action 3.2

I have some scripts (complete programs, like chess, checkers, etc.) I'd like to run via Custom Action, but some have their own log in, and others don't.
I'd like the scripts to be run using the SMF user system automatically, like a separate mod, I guess.
Would the code in the following quote help, or is there more to it?

Quote from: worm82075 on March 17, 2008, 08:47:48 AM
Awesome Mod, works like a charm, so I have no problem with it's function, my question is about it's use.

Ok, I have archived another site and what I'm working with is about 370 static html pages with css formating. I can see the ability to add the existing code to custom actions editing all links to point to those actions there by integrating the static set into my 1.1.4 SMF forum and it acting as it did before accept it will be surrounded by my header and footer. Ok, that is nearly perfect except I don't want to let guests have access to those actions. From what I've gathered from this thread is that making the action Php rather than Html will give me the ability to put a user check in every action. While I am fairly proficient with html I am not very familiar with  Php as of yet. I have a deadline to meet on the construction of my site otherwise I would just be learning Php and doing this on my own.

My question is this, Is it possible for me to create the action as php, giving me my user check and then have it parse Html code to construct the page. Or alternatively is there a program available that can convert my html code to php.

Any help concerning the possession and regulation of standard html code by SMF would be appreciated. From what I gathered so far in the past 24 hours scouring this site for anything related to this subject is all the solutions in involve transforming my html code to php. Alright well there you have it, I'm sure someone here can enlighten me as to all my options so I can then decide what the best course of action will be.

Jeremy aka Worm

EDIT:I have located a program to convert my html to php and it works!

So all I really need now is a snipet to place at the beginning of my code to dis allow guests.

EDIT 2:ok, I managed to scrounge the first part and it works right
if ($context['user']['is_guest'])
echo "You <FONT color=#ff0000><b>MUST</b></FONT> be a registered member of this site to enter this archive.<BR><BR><BR>";

i just need to be able to kill it at this point if guest checks true

EDIT 3: Well that didn't take much time
if ($context['user']['is_guest'])
die('Direct Access to this location is not allowed.');

I have been at this site at least a half a dozen times for help. This is the first time I actually posted thinking what i needed wasn't here. Just took me a little longer to find it this time thats all. Leave it to a bunch of forum creators to set the example of how to run a tight ship. Thanks
30 years ago I was young and foolish.
Now I'm just young.


Dave's Games


Quote from: DanCarroll on October 25, 2011, 01:58:12 PM
Hopefully this helps someone. I had to go through a long process of hand-crafting a custom action to understand how all of the parts worked.
Custom Actions with Link Tree. Cool way to go.

Cool way indeed, very useful, could a link to this be added to the first post? Save others from searching through the pages for the useful bits.

Thanks  ;)


Done, thanks for the feedback, geek_andy.

And in particular, thanks to DanCarroll for the time spent on it and for sharing his experience.
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker

Also known as Norv on D* | Norv N. on G+ | Norv on Github


This mod works great!
I have a question though that I hope someone can answer for me.

This is what I have in the 'body' part:

<iframe src="" width="647" height="400"></iframe>

My question is, what do I add to this to have it a popup window instead of being in the forum page?


I want to use this mod to add as custom action an application made with zend framework. Can this be done?
Can anyone please share a quick solution or post some related "reading" material?


I installed this mod and made a test page, but when I go to it I get the following error in my error log.

8: Undefined index: level
File: /homepages/13/xxxxxxxxxx/htdocs/xxxxx/community/Sources/menu_source/resources/main.php
Line: 994

Any ideas?

If it helps, line 994 of that file is as follows:
if (!empty($temp['strstr'][$key]) && $temp['strstr'][$key] == $context['current_action'] && $value['level'] == 0)


I want to add an imprint to my forum as required here in good old germany :-\

I read that this should be easy to achieve with this tool (otherwise I need to update all themes as it seems).

I got an imprint as .php-file - how can I do this now?

Can I chose type = PHP and do an include 'myfile.php'; in the Source File Code-field? Do I need to define an Action URL? I think I don't need it, I just want a new menu entry in the main menu...

A simple tutorial would be quite useful, is there maybe some that I haven't found?

Got it:


Hey UNeverNo,

Does the script output something? If so, put it in the template box.

Just place it like this:

// $boarddir contains the path to the SMF directory, so perhaps it's /var/www/smf
global $boarddir;



Good luck!
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."