logo

Member
Member
Offline Offline
Posts: 46
Suggestion: Use all database (and admin editable) links

Something I changed on my site, and I would suggest be default... rather than have a mix of hard-coded links and database-loaded links on the navbar, switching to all database links.

Such that Home, Messages, Profile, Forum, etc are all editable on the admin page.

My layout - links.php - links function, note that there's not a single hard coded link.
Code:

function links()
{
   global $user, $authid, $settings;
   $body = '
<div class="navbar">
  <ul>';
   $headerlinkquery = call('sql_query', "SELECT * FROM menu ORDER BY item_order ASC", 'cache');
   foreach ($headerlinkquery as $headerlinkrow) {
       if (call('visiblecheck', $user['membergroup_id'], $headerlinkrow['rank'])) {
        if (empty($headerlinkrow['window']) || $headerlinkrow['window'] != 'popup') {
         $body .= '
   <li><a href="' . $headerlinkrow['link'] . ($headerlinkrow['authid'] == '1' ? '&amp;' . $authid : '') . '"' . ($headerlinkrow['window'] == 'new' ? ' target="_blank"' : '') . '>' . $headerlinkrow['name'] . '</a></li>';
        } elseif ($headerlinkrow['window'] == 'popup') {
         $body .= '<li><a href="javascript:;" onclick="window.open('' . $headerlinkrow['link'] . ($headerlinkrow['authid'] == '1' ? '&amp;' . $authid : '') . '','','width=' . $headerlinkrow['width'] . ',height=' . $headerlinkrow['height'] . '')">' . $headerlinkrow['name'] . '</a></li>
     ';
        }
       }
   }
   $body .= '
       </ul>
     </div>';
   return $body;
}


An example sql layout for a new site, see how I set only guest (rank 1) get login? Easily control who gets access to what this way, so perhaps only mods can message, and leave everyone access to profile, etc.
Code:

INSERT INTO `menu` (`id`, `name`, `link`, `item_order`, `rank`, `authid`, `window`, `height`, `width`) VALUES
(1, 'Home', 'http://www.site.org/index.php', '1', '1,2,3,4', 0, 'same', 0, 0),
(2, 'Forum', 'http://www.site.org/forum', '2', '1,2,3,4', 1, 'same', 0, 0),
(3, 'Messages', 'http://www.site.org/index.php?act=pm', '3', '2,3,4', 1, 'same', 0, 0),
(4, 'Logout', 'http://www.site.org/index.php?act=logout', '4', '2,3,4', 1, 'same', 0, 0),
(5, 'Login', 'http://www.site.org/index.php?act=login', '5', '1', 0, 'same', 0, 0),
(6, 'Profile', 'http://www.site.org/index.php?act=editprofile', '6', '2,3,4', 1, 'same', 0, 0),
(7, 'Admin', 'http://www.site.org/index.php?act=admin', '7', '4', 1, 'same', 0, 0);
Last Edit: 17th September, 2009, 04:20:04 PM by FWishbringer
eoCMS Designer
eoCMS Designer
Offline Offline
avatar
Posts: 291
haz_pwnd_u@yahoo.com
Re: Suggestion: Use all database (and admin editable) links

I'm in complete agreement with this, yet one more small thing that would help make the theme system seem even more customizable.  Thanks for posting this FWishbringer.
eoCMS Developer
eoCMS Developer
Offline Offline
avatar
Posts: 1528
Re: Suggestion: Use all database (and admin editable) links

Done

Please do not PM me requesting support or anything, use the forums, thats what they are here for
Global Moderator
Global Moderator
Offline Offline
Posts: 122
Re: Suggestion: Use all database (and admin editable) links

Thank you!  A fantastic suggestion.  Grin

Arwym's Domain  ||  SBM: A PHP Bookmarks Script (coming soon)

Jump to:


0.07 seconds Queries: 13