HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


How to change the default module breadcrumbs

Login / Search

 [ Join | More ]
 
Posted
Rating:
#23962 (In Topic #5749)
Avatar

ocPortal is a module-based CMS. This means that primarily, data is organised in terms of the modules it belongs to. The breadcrumbs in ocPortal largely reflect this, although there is some customisability built in.
If someone needs to build a website that is based on a structured navigation independant of modules, then we typically recommend that this be done via creating a tree of Comcode pages and putting content blocks on those pages (e.g. main_cc_embed. However, once you go and view a full-page entry, the ocPortal modular-based breadcrumbs will still be there.

It wouldn't really be appropriate for us to code in some way of configuring this, as it'd make the user-interface get very-complex, very-fast. Instead, we like to make it so the PHP code can be changed in a modular fashion.

A customer today faced the problem I described. He wanted the contents of his catalogue named 'dictionary' (with title 'Dictionary') to be displayed as if it was underneath a Comcode page with a pagelink of 'site:dictionary'.
As this would involve a complex code change, that I feel is useful to many, I've decided to do it myself and release it.

To make the change, simply make a new override file named sources_custom/site.php:

PHP code

<?php

/**
 * Get the tempcode for the breadcrumbs.
 *
 * @return tempcode       The breadcrumbs
 */
function breadcrumbs()
{
   global 
$BREADCRUMB_SET_PARENTS,$BREADCRUMBS,$BREADCRUMB_EXTRA_SEGMENTS;

   
// Data
   
$target_url=build_url(array('page'=>'dictionary'),'site');
   
$segment_substitutions=array(
      
'\<a title="[^"]*" href="[^"]*/site/index.php\?page=catalogues&amp;type=misc[^"]*"\>Catalogues\</a\> &gt; '=>'',
      
'\<a title="[^"]*" href="[^"]*/site/index.php\?page=catalogues&amp;type=index&amp;id=contacts[^"]*"\>Index\</a\> &gt; '=>'<a title="Go backwards to" href="'.$target_url->evaluate().'">Dictionary</a> &gt; ',
   );

   if (
is_null($BREADCRUMBS))
   {
      
$BREADCRUMBS=breadcrumbs_get_default_stub($BREADCRUMB_EXTRA_SEGMENTS->is_blank());
   }
   
$out=$BREADCRUMBS;
   if (!
$BREADCRUMB_EXTRA_SEGMENTS->is_blank())
   {
      if (!
$out->is_blank()) $out->attach(do_template('BREADCRUMB_ESCAPED'));
      
$out->attach($BREADCRUMB_EXTRA_SEGMENTS);
   }
   if (
count($segment_substitutions)!=0)
   {
      
$out=$out->evaluate();
      foreach (
$segment_substitutions as $from=>$to)
      {
         
$out=preg_replace('#'.$from.'#',$to,$out);
      }
   }
   return 
$out;
}

?>

This would need customising depending on exactly what breadcrumb changes you wanted to do. But I've written it in such a way as for it to be relatively easy to extend and modify, if you know some basic PHP.

I realise this is really quite complex, so feel free to ask questions.


Last edit: by Chris Graham


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#23968
Avatar

Community saint

Gotcha!!

A couple of minor edits and it works exactly how you said it would.

I hesitate to ask - but what the hell, if I don't ask I don't get!

I have an identical scenario for another page, so how do I insert it into this "sources_custom/site.php" so that either/or is actioned when called?

I've tried inserting "else if" all over the place but it just breaks, so it's pretty obvious that my PHP coding knowledge is minimal to non-existant!!

 :(

Take my advice. I'm not using it!

View my working ocPortal site (version 9.x.x) at Anglo-Indian Portal
Back to the top
 
Posted
Rating:
#23979
Avatar

Pretending you want the foo catalogue (entitled Foo) to be linked to from the bar page (entitled Bar), you'd modify the lines underneath "// data"…

PHP code

   $target_url=build_url(array('page'=>'dictionary'),'site');
   
$target_url_2=build_url(array('page'=>'bar'),'site');
   
$segment_substitutions=array(
      
'\<a title="[^"]*" href="[^"]*/site/index.php\?page=catalogues&amp;type=misc[^"]*"\>Catalogues\</a\> &gt; '=>'',
      
'\<a title="[^"]*" href="[^"]*/site/index.php\?page=catalogues&amp;type=index&amp;id=contacts[^"]*"\>Index\</a\> &gt; '=>'<a title="Go backwards to" href="'.$target_url->evaluate().'">Dictionary</a> &gt; ',
      
'\<a title="[^"]*" href="[^"]*/site/index.php\?page=catalogues&amp;type=index&amp;id=foo[^"]*"\>Index\</a\> &gt; '=>'<a title="Go backwards to" href="'.$target_url_2->evaluate().'">Bar</a> &gt; ',
   );



Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#23995
Avatar

Community saint

Hmmmm . . .

Doesn't work for me, but that's probably because I screwed up with the original catalogue/page setup, so I'll look again.  I can see HOW the script is assembled, I just don't know what I've done wrong to stop it working.  Here's how it currently appears in my new "custom_sources/site.php":

Code (php)

   // Data
   $target_url=build_url(array('page'=>'dictionary'),'site');
   $target_url_2=build_url (array('page'=>'aidirectory'),'site');
   $segment_substitutions=array(
      '\<a title="[^"]*" href="[^"]*/site/index.php\?page=catalogues&amp;type=misc[^"]*"\>Catalogues\</a\> &gt; '=>'',
      '\<a title="[^"]*" href="[^"]*/site/index.php\?page=catalogues&amp;type=index&amp;id=dictionary[^"]*"\>Index\</a\> &gt; '=>'<a title="Go backwards to" href="'.$target_url->evaluate().'">A-I Dictionary</a> &gt; ',
      '\<a title="[^"]*" href="[^"]*/site/index.php\?page=catalogues&amp;type=index&amp;id=aidirectory[^"]*"\>Index\</a\> &gt; '=>'<a title="Go backwards to" href="'.$target_url_2->evaluate().'">A-I Directory</a> &gt; ',
   );
 

The first 'redirect' works pefectly; the second still takes me back to the Catalogue Index.

But thanks for trying.

Take my advice. I'm not using it!

View my working ocPortal site (version 9.x.x) at Anglo-Indian Portal
Back to the top
 
Posted
Rating:
#23996
Avatar

Community saint

Chris,

One significant (I think it is significant) point about the A-I Directory is that it is linked under 'Root', probably because I imported these from a phpNuke database under the umbrella of 'Contacts'.

The same applies to my 'Links' that were also imported.

All the others have been built locally, so that when I interrogate Catalogues they immediately show a direct link/breakdown, without appearing under 'Root'.

I hope that made sense.

 :dry:

Take my advice. I'm not using it!

View my working ocPortal site (version 9.x.x) at Anglo-Indian Portal
Back to the top
 
Posted
Rating:
#24008
Avatar

Yeah, that'd explain it.

Fingers crossed…

Code

   // Data
   $target_url=build_url(array('page'=>'dictionary'),'site');
   $target_url_2=build_url (array('page'=>'aidirectory'),'site');
   $segment_substitutions=array(
      '\<a title="[^"]*" href="[^"]*/site/index.php\?page=catalogues&amp;type=misc[^"]*"\>Catalogues\</a\> &gt; '=>'',
      '\<a title="[^"]*" href="[^"]*/site/index.php\?page=catalogues&amp;type=index&amp;id=dictionary[^"]*"\>Index\</a\> &gt; '=>'<a title="Go backwards to" href="'.$target_url->evaluate().'">A-I Dictionary</a> &gt; ',
      '\<a title="[^"]*" href="[^"]*/site/index.php\?page=catalogues&amp;catalogue_name=aidirectory&amp;type=category&amp;id=75[^"]*"\>Index\</a\> &gt; '=>'<a title="Go backwards to" href="'.$target_url_2->evaluate().'">A-I Directory</a> &gt; ',
   );

Btw, it looks like your ocp2_cache table has got corrupted due to some kind of server malfunction. Possibly a disk-full problem :(.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#24013
Avatar

Community saint

My site has been off for several hours now . . .

If I DROP the oc2_cache table will ocP rebuild it, or do I have to rebuild it myself . . . and how?

 :@

Take my advice. I'm not using it!

View my working ocPortal site (version 9.x.x) at Anglo-Indian Portal
Back to the top
 
Posted
Rating:
#24014
Avatar

You can drop it and then run this query:

Code

CREATE TABLE `ocp2_cache` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `cached_for` varchar(80) NOT NULL,
  `identifier` varchar(255) NOT NULL,
  `the_value` longtext NOT NULL,
  `date_and_time` int(10) unsigned NOT NULL,
  `the_theme` varchar(80) NOT NULL,
  `lang` varchar(5) NOT NULL,
  `langs_required` longtext NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `cached_for` (`cached_for`)
) ;


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#24015
Avatar

Community saint

Thanks . . will give it a go now

Take my advice. I'm not using it!

View my working ocPortal site (version 9.x.x) at Anglo-Indian Portal
Back to the top
 
Posted
Rating:
#24016
Avatar

Community saint

You're some kind of "Santo Christoph". Rebuilt the ocp2_cache and the site is BOL.

My web hosts have been scratching their heads over this since 01:27 this morning, and responded a little while ago with the advice to check the coding in my script 'lang.php' (that's the error that I've been getting about "Unsupported operand types").

I might enlighten them - on the other hand I promised them that I would look for a more robust and helpful web host today, and I will probably still do that . . .!!

Now to try the 'fix' you included in that previous post.

Thanks, again.

Take my advice. I'm not using it!

View my working ocPortal site (version 9.x.x) at Anglo-Indian Portal
Back to the top
 
Posted
Rating:
#24017
Avatar

Actually, to be fair, there was a previous error but I fixed that myself just before posting. The lang cache files had become blank, and hence corrupt.
When that kind of thing happens, it's because the server went dodgy, so both that and the mySQL thing had a common cause.
I've also made a small change to ocPortal which will be in the next release to make it auto-recover from blanked language cache files.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#24018
Avatar

Community saint

"custom_sources/site.php"

The 'fix' refuses to work.  When I mouseover the breadcrumb 'A-I Directory' I get the following in the status bar:

Somehow it still seems to want to go back to the root id and refuses to pause at 'id=75'.

Bummer!!

Take my advice. I'm not using it!

View my working ocPortal site (version 9.x.x) at Anglo-Indian Portal
Back to the top
 
Posted
Rating:
#24248
Avatar

Sorry for the late reply – my computer died almost right after you posted.

I made a small mistake in what I posted. Please remove:

Code

&amp;catalogue_name=aidirectory
from it, as that isn't actually represented in the URL that needs replacing.

I was guessing at what the URL would be when I was viewing the site before, because if I remember correctly, the server problems were stopping me seeing the breadcrumbs used.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#24259
Avatar

Community saint

I saw your post about your comp trubs, so guessed you were pretty snowed. I clean mine out every couple of months - dog hairs are murder!!

I will give your 'edit' a try, but I've already tried a combination of several URLs as shown by the navigation and the Site Tree.  I've even tried adding the "root=75" in desperation, but that doesn't seem to work either.

Will report back with results - or not!

 O_o

Take my advice. I'm not using it!

View my working ocPortal site (version 9.x.x) at Anglo-Indian Portal
Back to the top
 
Posted
Rating:
#24269
Avatar

Community saint

Chris,

I've given it a good workout, but it refuses to play ball, no matter what . . .

Some observations:
1. The A-I Directory 'cover page' link is:

Code

http://www.maltap.com/anglo/site/index.php?page=aidirectory&keep_session=8686426
2. The Breadcrumb link back is:

Code

http://www.maltap.com/anglo/site/index.php?page=catalogues&type=category&id=75&root=75&keep_session=8686426
3. The 'wierd' hierarchy created by the php-Nuke import is shown in this attachment:



Take my advice. I'm not using it!

View my working ocPortal site (version 9.x.x) at Anglo-Indian Portal
Back to the top
 
Posted
Rating:
#24296
Avatar

I got the link text wrong. Fingers-crossed again.

Code

   // Data
   $target_url=build_url(array('page'=>'dictionary'),'site');
   $target_url_2=build_url (array('page'=>'aidirectory'),'site');
   $segment_substitutions=array(
      '\<a title="[^"]*" href="[^"]*/site/index.php\?page=catalogues&amp;type=misc[^"]*"\>Catalogues\</a\> &gt; '=>'',
      '\<a title="[^"]*" href="[^"]*/site/index.php\?page=catalogues&amp;type=index&amp;id=dictionary[^"]*"\>Index\</a\> &gt; '=>'<a title="Go backwards to" href="'.$target_url->evaluate().'">A-I Dictionary</a> &gt; ',
      '\<a title="[^"]*" href="[^"]*/site/index.php\?page=catalogues&amp;catalogue_name=aidirectory&amp;type=category&amp;id=75[^"]*"\>A-I Directory\</a\> &gt; '=>'<a title="Go backwards to" href="'.$target_url_2->evaluate().'">A-I Directory</a> &gt; ',
   );


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#24306
Avatar

Community saint

OK, you can uncross your fingers.
I had to edit out the bit that said "catalogue_name=" because that doesn't appear in any tree link that I've seen.

Here's the working code (really only matters to me, but thought I'd post it in case somebody else is following to obtain a similar fix!!):

Code (php)

[html]'dictionary'),'site');
   $target_url_2=build_url (array('page'=>'aidirectory'),'site');
   $segment_substitutions=array(
      '\<a title="[^" ]*"="]*"" ref="[^" ]*/site/index.php\?page="catalogues&amp;type=misc[^"]*"\">Catalogues\ &gt; '=>'',
      '\<a title="[^" ]*"="]*"" ref="[^" ]*/site/index.php\?page="catalogues&amp;type=index&amp;id=dictionary[^"]*"\">Index\ &gt; '=>'<a title="Go backwards to" href="'.$target_url->evaluate().'">A-I Dictionary</a> &gt; ',
      '\<a title="[^" ]*"="]*"" ref="[^" ]*/site/index.php\?page="catalogues&amp;type=category&amp;id=75[^"]*"\">A-I Directory\ &gt; '=>'<a title="Go backwards to" href="'.$target_url_2->evaluate().'">A-I Directory</a> &gt; ',
   );</a></a></a>[/html]

Thanks for all the help.


Last edit: by Fletch

Take my advice. I'm not using it!

View my working ocPortal site (version 9.x.x) at Anglo-Indian Portal
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: