News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

Subaction Help

Started by RRasco, March 14, 2007, 04:56:42 PM

Previous topic - Next topic

RRasco

I am working on a mod and wanted to change my menu to a tabbed style to flow with SMF.  I cant find any documentation on subactions....anyone have any advice on how to create them?  i am already familiar with custom actions.
Vehicle Management System for SMF - SMFGarage.com

codenaught

Which part are you referring to? The admin panel? The profile section? The main menu?
Dev Consultant
Former SMF Doc Coordinator

RRasco

its going to be for a custom action.  i am developing SMF Garage, which will be like phpBB Garage and  VB's Timeslips db.  i have created a custom tab and action to represent this page...

http://s164060672.onlinehome.us/sandbox/garage/smf/index.php?action=garage

I want to convert the menu on the left into another tabbed section like found on the memberlist.  and create subactions for those tabs.
Vehicle Management System for SMF - SMFGarage.com

codenaught

Well you can first take a look at how SMF does it in the Display template for example.

It first builds an array in this fashion:

// Build the normal button array.
$normal_buttons = array(
'reply' => array('test' => 'can_reply', 'text' => 146, 'image' => 'reply.gif', 'lang' => true, 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';num_replies=' . $context['num_replies']),
'notify' => array('test' => 'can_mark_notify', 'text' => 125, 'image' => 'notify.gif', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . ($context['is_marked_notify'] ? $txt['notification_disable_topic'] : $txt['notification_enable_topic']) . '\');"', 'url' => $scripturl . '?action=notify;sa=' . ($context['is_marked_notify'] ? 'off' : 'on') . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';sesc=' . $context['session_id']),
'custom' => array(),
'send' => array('test' => 'can_send_topic', 'text' => 707, 'image' => 'sendtopic.gif', 'lang' => true, 'url' => $scripturl . '?action=sendtopic;topic=' . $context['current_topic'] . '.0'),
'print' => array('text' => 465, 'image' => 'print.gif', 'lang' => true, 'custom' => 'target="_blank"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'),
);

// Special case for the custom one.
if ($context['user']['is_logged'] && $settings['show_mark_read'])
$normal_buttons['custom'] = array('text' => 'mark_unread', 'image' => 'markunread.gif', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';sesc=' . $context['session_id']);
elseif ($context['can_add_poll'])
$normal_buttons['custom'] = array('text' => 'add_poll', 'image' => 'add_poll.gif', 'lang' => true, 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start'] . ';sesc=' . $context['session_id']);
else
unset($normal_buttons['custom']);


test is the permission required to see the tab. text is the index of the $txt array for the text to be shown. Something like $txt['this_is_the_index']. image is the name of the image, which would be used for older themes that don't use the Core style tabs. lang you can just set to true (I don't see it actually used in the function). url is the address the tab takes you to. Just be sure to include $scripturl in it.

Then it uses the function template_button_strip() to output the tabs.

<table cellpadding="0" cellspacing="0">
<tr>
', template_button_strip($normal_buttons, 'bottom'), '
</tr>
</table>


PS: Your mod is looking nice. :)
Dev Consultant
Former SMF Doc Coordinator

RRasco

thanks a million, that helped alot.

where do i make modifications to the permissions, or add extra ones?
Vehicle Management System for SMF - SMFGarage.com

RRasco

ok, so i have skewed a little from this.....i have begun using memberlist.php as a comparison for creating subactions, ie.....

index.php?action=garage;sa=main

index.php?action=garage;sa=browse

thanks for all your help!
Vehicle Management System for SMF - SMFGarage.com

codenaught

Quote from: RRasco on March 15, 2007, 10:25:48 AM
where do i make modifications to the permissions, or add extra ones?

Well the 'test' => 'permission_name' calls $context['permission_name'], so you would assign $context['permission_name'] to something like allowedTo('permission_name'). I'm not sure if you know how to create custom permissions, but it involves adding the permission to the $permissionList array in ManagePermissions.php. This document should be able to help with that bit.
Dev Consultant
Former SMF Doc Coordinator

RRasco

yeah i had already read up on that doc, never found those docs before, they are a plus.  anyway, thanks for your help!
Vehicle Management System for SMF - SMFGarage.com

Advertisement: