• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: path plug-in
PostPosted: Tue Nov 16, 2004 12:05 am 
It would be nice to have a path plug-in. It would display the structure up to current page. For example:
Quote:
Home -> Services -> Consulting


Any suggestions?


Top
  
 
 Post subject: how do i get page id?
PostPosted: Tue Nov 16, 2004 12:56 pm 
Also I need to know how to get page id and page parent id.

thank you...


Top
  
 
 Post subject: Take a look at the bulletmenu plugin
PostPosted: Fri Nov 19, 2004 1:58 pm 
Hi Haberman!

Take a look at the bulletmenu plugin (found in /plugins/function.bulletmenu.php)

It calls upon a standard function:
Code:
   $content = db_get_menu_items($newparams);


db_get_menu_items returns an array of nested objects representing the entire menu hierarchy. You can then traverse it to plot the path to the current page.

To take a look at the structure db_get_menu_items returns, use the php var_dump function.

I'm not sure how to get the current page_id yet - if I find out, I'll post back.


Top
  
 
 Post subject: Finding current page
PostPosted: Fri Nov 19, 2004 3:37 pm 
Thanks for the info goes to wishy...
Code:
global $gCms;
$thispage = $gCms->variables['page'];


This is the page_id of the current page.


Top
  
 
 Post subject: OK, I'll write the code...
PostPosted: Fri Nov 19, 2004 5:58 pm 
Seeing as I got started!

Note: This plugin requires at least revision 863 from subversion.
This is because it uses a new function called getURL (found in /lib/page.functions.php) to find out the URL of each page.

Code:
<?php
#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://cmsmadesimple.sf.net
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

function smarty_cms_function_breadcrumbs($params, &$smarty) {

   global $db;
   global $gCms;
   
   $thispage = $gCms->variables['page'];

   # track - identify all ancestors of current page
   $parent = $thispage;
   $breadcrumbs = array();
   
   # gather data
   while ($parent != 0) {
      $query   = "SELECT * FROM ".cms_db_prefix()."pages WHERE page_id = '$parent'";
      $result = $db->Execute($query);
      if ($result && $result->RowCount() > 0) {
         $line   = $result->FetchRow();
         $parent   = $line["parent_id"];

         $current_content = new Page;
         $current_content->page_id      = $line["page_id"];
         $current_content->page_title   = $line["page_title"];
         $current_content->page_alias   = $line["page_alias"];
         $current_content->page_url      = $line["page_url"];
         $current_content->menu_text      = $line["menu_text"];
         $current_content->page_type      = $line["page_type"];
         $current_content->item_order   = $line["item_order"];
         $current_content->active      = $line["active"];
         $current_content->show_in_menu   = $line["show_in_menu"];
         $current_content->default_page   = $line["default_page"];
         $current_content->username      = $line["username"];
         $current_content->template_name = $line["template_name"];
         $current_content->parent_id      = $line["parent_id"];
         if (isset($line["url"])) $current_content->url = $line["url"];
         array_push($breadcrumbs, $current_content);
      }
   }

   $trail = "";
   # process $breadcrumbs
   while ($a = array_pop($breadcrumbs)) {
      if ($a->page_id != $thispage && $a->page_type != 'seperator') {
         if (getURL($thispage)!="") $trail .= "<a href=\"".getURL($a)."\">".$a->page_title."</a> >>\n";
         else $trail .= $a->page_title." >> \n";
      } else {
         $trail .= "<strong>".$a->page_title."</strong>\n";
      }
   }

   return $trail;

}

function smarty_cms_help_function_breadcrumbs() {
   ?>
   <h3>What does this do?</h3>
   <p>Prints a breadcrumb trail .</p>
   <h3>How do I use it?</h3>
   <p>Just insert the tag into your template/page like: <code>{breadcrumbs}</code></p>
   <h3>What parameters does it take?</h3>
   <p>
      No parameters at the moment, a future release may allow you to change what goes between each page.
   </p>


   <?php
}

function smarty_cms_about_function_breadcrumbs() {
   ?>
   <p>Author: Marcus Deglos <<a href="mailto:md@zioncore.com">md@zioncore.com</a>></p>
   <p>Version: 1.0</p>
   <p>
   Change History:<br/>
   None
   </p>
   <?php
}

# vim:ts=4 sw=4 noet
?>


Save this as 'functions.breadcrumbs.php' in your plugins directory.
Call it on a page or template using {breadcrumbs}.

Marcus


Top
  
 
 Post subject: path plug-in  [SOLVED]
PostPosted: Fri Nov 19, 2004 9:28 pm 
Offline
Power Poster
Power Poster

Joined: Sun Sep 26, 2004 6:15 pm
Posts: 599
Location: Saskatchewan - Canada
Works in a template but not on a page. Am up to changeset 865.
htmlarea strips it out of the code :?:

_________________
Greg


Top
 Profile  
 
 Post subject: HTMLAREA bugs
PostPosted: Fri Nov 19, 2004 9:32 pm 
HTMLAREA has issues :|

use the <> switch to go to 'source editing' mode.
the {breadcrumbs} tag should stay then.

Oh, there's no html tagging around the output, so you can add
Code:
<p>{breadcrumbs}</p>
or similar to make it more presentable.


Top
  
 
 Post subject: path plug-in
PostPosted: Fri Nov 19, 2004 9:45 pm 
Offline
Power Poster
Power Poster

Joined: Sun Sep 26, 2004 6:15 pm
Posts: 599
Location: Saskatchewan - Canada
<> works until you do a preview or switch back to WYSIWYG.
Enclosing in a P tag worked, thanks.

_________________
Greg


Top
 Profile  
 
 Post subject: Watch for updates
PostPosted: Fri Nov 19, 2004 9:54 pm 
NP.

By the way, the version above is *already* old - so keep an eye on SVN: it should join the tree shortly. Hopefully, the latest version will always be found on SVN.


Top
  
 
 Post subject: Path plug-in: SOLVED!
PostPosted: Wed Nov 24, 2004 8:14 pm 
Ok, guys I see I started good topic. I was short on time so I started to work on it myself. And I did it. I was reviewing the bullet menu an write this code:
Code:
global $db;
global $gCms;
$current_page = $gCms->variables['page'];

        # getting content
        $content = db_get_menu_items($newparams);
       
#variable definition
$separator = " / ";
$path = "";
$home = "";

# displays path up to 10 levels
for ($i = 1; $i <= 10; $i++)
{       
 foreach ($content as $one)
 {
        # searching current page
        if ($one->hier == 1) $home = '<a href="'.$one->url.'">'.$one->menu_text.'</a>';
        # searching current page
        if ($one->page_id == $current_page)
                 {
                  $path = $separator.'<a href="'.$one->url.'">'.$one->menu_text.'</a>'.$path;
                  $current_page = $one->parent_id;
                  if ($current_page == 0) break;
                 }
 }
}
$path = $home.$path;
echo $path;

I don't know if its bullet proof, but it works on my version of CMS. To install it paste the code into plugin area and name it as you wish.

Enjoy ;-)


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting