PDA


View Full Version : How do I get breadcrumbs to follow added pages


kgeronilla
03-15-2005, 12:06 AM
I have added 3 CMPS pages. I would like breadcrumbs in the navbar to show the following when on page3.

Index > page1 > page 2
|
|__page3

I have only found one other post on this (thread link (http://www.vbadvanced.com/forum/showthread.php?t=2355)), but I still don't understand how to get this working. I figure this will take a bit of work, but I'm not sure how to get started with this.

Tom M
03-15-2005, 01:32 AM
For you to make your own breadcrumb information using CMPS you need to start by editing the vba_cmps_include.php file found in the www.yourdomain.com/forums/include directory to allow the breadcrumb information to be updated by the content module.

In the vba_cmps_include_bottom.php file

Find the following code sections
$headinclude = str_replace(
array(
'"clientscript',
'url(images/',
'name="generator" content="'
),
array(
'"' . $vboptions['bburl'] . '/clientscript',
'url(' . $vboptions['bburl'] . '/images/',
'name="generator" content="vBadvanced, '
),
$headinclude
);

// $navbar replacement
if (THIS_SCRIPT == 'adv_index')
{
$navreplacearray = explode("\r\n", $vba_options['global_navbar_replace']);

$navreplace['find'] = array(
'"clientscript',
'\'misc.php',
'>$vboptions[bbtitle]',
'"$vboptions[forumhome].php'
);

$navreplace['replace'] = array(
'"' . $vboptions['bburl'] . '/clientscript',
'\'' . $vboptions['bburl'] . '/misc.php',
'>$vboptions[hometitle]',
'"$vboptions[homeurl]'
);

$navreplace = construct_replacement_array($navreplacearray, $navreplace);

$templatecache['navbar'] = str_replace($navreplace['find'], $navreplace['replace'], $templatecache['navbar']);
}

And move it in front of
// Process Active Modules
if (is_array($modules))


To set your own breadcrumb info in your module you need to do something like
$navbits = array("/index.php?page=xxx" => "page1", "/index.php?page=yyy" => "page2");
$navbits[''] = "page3";
$navbits = construct_navbits($navbits);

// decide which navbar method is needed
if ($vba_options['portal_version'] == '1.0.0')
$navbar = construct_adv_navbar($navbits);
else
eval('$navbar = "' . fetch_template('navbar') . '";');

You can see this in use on my Recommendations (http://www.babblers.org/index.php?pg=recommend) pages.

kgeronilla
03-15-2005, 11:56 AM
Thanks for the help Tom that is exactly what I needed to know. I noticed you have a lot of pages. Did you add code to vba_cmps_include_bottom.php for each page, or is there a way to pass variables from templates.

Tom M
03-15-2005, 12:08 PM
Not completely sure which your talking about :(. I pass information both via the url as paramters (?page=mypage&do=this&action=that) and as hidden form variables when information needs to travel from one page to another.

Brian
03-15-2005, 12:11 PM
Just an FYI, this will be a standard feature in 2.0. ;)

Tom M
03-15-2005, 12:30 PM
Just an FYI, this will be a standard feature in 2.0. ;)That's great Brian. Will the existing code be backward compatible? How about a hint at a target date? :)

Brian
03-15-2005, 01:03 PM
I haven't looked at the hack, but I seriously doubt it. No clue on a target date yet. It's getting there though. :)

kgeronilla
03-15-2005, 07:31 PM
Not completely sure which your talking about :(. I pass information both via the url as paramters (?page=mypage&do=this&action=that) and as hidden form variables when information needs to travel from one page to another.

I was hoping there was a way I could put the breadcrumb information in a template and pass that information to vba_cmps_include_bottom.php. If for example, I had 3 pages in the breadcrumbs. I would like to pass the following info

URL and title of crumb 1
URL and title of crumb 2
URL and title of crumb 3

Then write some kind of function in vba_cmps_include_bottom.php to generate the proper breadcrumbs in the navbar.

Right now I’m just writing if statements combined with the code you posted to generate the correct breadcrumbs for each page.

if ($pages['name'] == 'page3')
{
$navbits = array( $page=page1 => "title_page1", $page=page2 => "title_page2");
$navbits[''] = "title_page3";
$navbits = construct_navbits($navbits);

// decide which navbar method is needed
if ($vba_options['portal_version'] == '1.0.0')
$navbar = construct_adv_navbar($navbits);
else
eval('$navbar = "' . fetch_template('navbar') . '";');
}

Is there an easier way to do this?

Tom M
03-15-2005, 08:30 PM
How do you get from page to page? Do you have a link to look at?

kgeronilla
03-15-2005, 09:26 PM
I'm using normal text links that link page1 to Page2 to page3.

Tom M
03-15-2005, 09:27 PM
I'm using normal text links that link page1 to Page2 to page3.Sorry. I meant a web page link :)

kgeronilla
03-15-2005, 11:50 PM
Sure thing. The pages are Rivers/Creeks ---> Maryland ---> Upper Yough

http://www.boateraccess.com/index.php?page=riversindex

Tom M
03-16-2005, 12:05 AM
I approached mine in a different manner. Instead of using separate pages the php module determines which templates to load based on the incoming action requests. This means there's one master template that acts as the wrapper for all the related pages with a bit of conditional code in it as well. The other content, and which templates to use, is determined on the fly by the module. It actually makes things a bit easier as the module can derive the structure that's needed based on the db organization. It also means the same templates get reused as it's just the content that's being changed.

The only "tricky" part is that you then need to pass the information to the module on the next invocation. Using your example it might be ilke this...

index.php?page=riversindex&state=md&river=upper_yough

If the rivers are being indexed in a database you might just use the river id's

index.php?page=riversindex&rid=37

Where the entry for river id 37 might contain the state and river name.

Lots of ways to do it. If you're doing in manually as self maintained content then the first method may be the best way.