TinyPortal

Development => Support => Topic started by: misfitmafia on May 13, 2008, 11:30:33 PM

Title: Custom Action
Post by: misfitmafia on May 13, 2008, 11:30:33 PM
I need some help using blocks with Custom Actions. When I create a center block and give it a custom action such as "aboutus", the link to show this block would be www.mysite.com/index.php?action=aboutus. The Block and content show up fine but so does the forum below the block. My problem is that I do not want the forum displayed below the block, is there anyway to keep the forum from displaying when using a custom action to display a center block?
Title: Re: Custom Action
Post by: JPDeni on May 14, 2008, 12:25:51 AM
I'm not sure if I understand what you're doing, but I think a better choice would be to use an article instead of a block.
Title: Re: Custom Action
Post by: misfitmafia on May 14, 2008, 01:02:05 PM
I originally used a article but articles so not use ?action= and I need this for the menu to work correctly. Also the block has built in membergroup permissions, I am writing some scipts for cetian users to use to make changes to the database and I do not want people randomly trying article numbers to access the scripts.

I know there has to be a way to disable the forum when viewing blocks via the ?action=. I just do not know what to modify. If someone could point me into the right direction I could figure out the code and fix it, thanks!!!
Title: Re: Custom Action
Post by: JPDeni on May 14, 2008, 02:09:30 PM
QuoteI know there has to be a way to disable the forum when viewing blocks via the ?action=.

Then I'll back out of the conversation, because you obviously know more about this than I do. :)
Title: Re: Custom Action
Post by: IchBin on May 14, 2008, 02:41:36 PM
misfit, there are several things you can do. You don't have to have something in an "action" to make the button work, as you can always add some PHP to make it work for articles.

if (isset($_GET['page']) && $_GET['page'] == 3)
     $current_action = 'page';


Then just set your button to use current action as page.

Then in your article you can always add code to check a membergroup. If the person is not in this member group they do not get to see or execute the block. I've posted the code for this many times, so a quick search of my posts you'll find out how.
Title: Re: Custom Action
Post by: misfitmafia on May 14, 2008, 03:38:23 PM
Thanks Ichbin, do i add that code in the template.index. The problem i was having with articles was adding them to the top menu, when adding the a link to an article the button did not work correctly because it was not an action.

But does anyone know why the forum shows up with blocks using custom actions. I have tried this on several of my forums and all of them act this same way, I just don't see why it always displays the forum under the block?
Title: Re: Custom Action
Post by: IchBin on May 14, 2008, 05:28:11 PM
You add that code to the template_menu function in the index.template.php file.

I don't quite get what you're saying in your last paragraph.
Title: Re: Custom Action
Post by: misfitmafia on May 14, 2008, 08:02:35 PM
If you visit the the site on working on www.inragecss.com/site/index.php and click the about us in the menu it will display the aboutus block but it also displays the forum right below it. I want to prevent the forum from displaying.
Title: Re: Custom Action
Post by: IchBin on May 14, 2008, 09:41:02 PM
action=aboutus ? Is that a mod or something that you've installed? TP doesn't have anything to do with action=aboutus.
Title: Re: Custom Action
Post by: misfitmafia on May 14, 2008, 10:07:54 PM
Its not a mod, I just created a center block and at the bottom under "custom action name" I put about us in the blank input box. I then edited the index template to create a new menu item with the link "?action=aboutus". Everything worked great except for the forum showing up under the block.
Title: Re: Custom Action
Post by: IchBin on May 14, 2008, 10:25:35 PM
Yes, but what you don't realize is that an action has to be defined in SMF. If the action is not defined it automatically forwards you to the forum. Thats why you are seeing the forum. Its actually a security feature of SMF, so that people can't just include anything they want to SMF's url and exploit something.
Title: Re: Custom Action
Post by: misfitmafia on May 15, 2008, 03:10:14 AM
OK that makes sense, I know if i try and action that has not been set it automatically shows the forum. How hard is it to define an action so it will display without showing the forum?

Your code you posted earlier worked out great, I was looking for something like that before and could not find it, thats what lead me to using blocks instead of articles, thanks for all the help!!
Title: Re: Custom Action
Post by: fangweile on May 15, 2008, 04:46:25 AM
There is a mod for custom action, have you searched the SMF site for this.
here is the link.
http://www.simplemachines.org/community/index.php?topic=86793.0
Title: Re: Custom Action
Post by: IchBin on May 15, 2008, 04:52:08 AM
How to create custom 'action'
http://www.simplemachines.org/community/index.php?topic=23864.0