Any suggestions?Home -> Services -> Consulting
path plug-in
path plug-in
It would be nice to have a path plug-in. It would display the structure up to current page. For example:
how do i get page id?
Also I need to know how to get page id and page parent id.
thank you...
thank you...
Take a look at the bulletmenu plugin
Hi Haberman!
Take a look at the bulletmenu plugin (found in /plugins/function.bulletmenu.php)
It calls upon a standard function:
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.
Take a look at the bulletmenu plugin (found in /plugins/function.bulletmenu.php)
It calls upon a standard function:
Code: Select all
$content = db_get_menu_items($newparams);
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.
Finding current page
Thanks for the info goes to wishy...
This is the page_id of the current page.
Code: Select all
global $gCms;
$thispage = $gCms->variables['page'];
OK, I'll write the code...
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.
Save this as 'functions.breadcrumbs.php' in your plugins directory.
Call it on a page or template using {breadcrumbs}.
Marcus
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: Select all
<?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
?>
Call it on a page or template using {breadcrumbs}.
Marcus
path plug-in
Works in a template but not on a page. Am up to changeset 865.
htmlarea strips it out of the code
htmlarea strips it out of the code
Greg
HTMLAREA bugs
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 or similar to make it more presentable.
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: Select all
<p>{breadcrumbs}</p>
path plug-in
works until you do a preview or switch back to WYSIWYG.
Enclosing in a P tag worked, thanks.
Enclosing in a P tag worked, thanks.
Greg
Watch for updates
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.
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.
Path plug-in: SOLVED!
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:
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
Code: Select all
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;
Enjoy