[Product-Developers] How do I change the breadcrumbs for acustom template?

Mark Phillips mark at phillipsmarketing.biz
Mon Dec 24 14:36:56 UTC 2007


Hi Tim,

Thanks for your ideas. I tried them out through the ZMI to see what
would happen. I am developing a new product, but using the old 2.x style
(Install.py) method. My next product will use GenericSetup. :-)

I added my template to the possible views for a page, created a blank
page at the root of my site (called front page), changed the display
parameter for front page to my template, and the correct page appeared.
However, the breadcrumbs now say:

	You are here: Home → front page

Instead of 

	You are here: Home → Members → mark → my-page

I did learn something about templates from your suggestion, so it was
valuable! :-)

I think I have to make changes to the actual template to get the bread
crumbs to be correct. My logic is - my template is based on the
main_template, and all I do is replace the main_slot with my code to
search for the correct page (see the template below).

If I could "override" the breadcrumbs that exist in the main_template,
with breadcrumbs that point to the page I found in the catalog search,
then the breadcrumbs would be correct. I just don't see how to do this
from staring at the main_template. Also, I don't know if this is the
correct approach.

Thanks for any other suggestions you may have!

Mark

On Sun, 2007-12-23 at 23:09 -0500, Tim Knapp wrote:
> Hi Mark,
> 
> Just a suggestion, which will *hopefully* resolve this issue for you
> (if you haven't tried it already):
> 
> Ensure the page is defined as a selectable view for say 'Page' and
> then you can click the display dropdown and select your defined page
> template. This should ensure you don't break the breadcrumbs.
> 
> To setup your custom template as a selectable view for Page using
> GenericSetup, do something like this in your product:
> e.g. profile/types/Document.xml ->  <property name="view_methods"
> purge="False">
> <element value="my_chosable_view"/>
> 
> If you're not developing a custom product (i.e. using ZopeSkel or
> DIYPloneStyle) you can go into portal_types and add your custom
> template under the view_methods property. Then create a new 'page' in
> the root of your site and select your template as the 'display' view.
> 
> HTH,
> Tim
> 
> On Sun, 2007-12-23 at 20:45 -0700, Mark Phillips wrote: 
> > I am using:
> > Plone 2.5.2, 
> > CMF-1.6.4, 
> > Zope (Zope 2.9.7-final, python 2.4.4, linux2), 
> > Five 1.4.2, 
> > Python 2.4.4 (#2, Aug 16 2007, 02:03:40) [GCC 4.1.3 20070812
> > (prerelease) (Debian 4.1.2-15)], 
> > PIL 1.1.6
> > 
> > I have created a page template for my home page. It searches the catalog
> > for the latest page with the keyword "lead story", and then displays
> > that page as the home page. However, the breadcrumbs show:
> > 
> > 	You are here: Home → portal_skins → custom 
> > 
> > I would like them to show:
> > 
> > 	You are here: Home → Members → mark → my-page
> > 
> > or where ever the actual page is located.
> > 
> > How do I change the breadcrumbs in my new template? 
> > 
> > Thanks!
> > 
> > Mark
> > 
> > The new page template:
> > 
> > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
> >       lang="en"
> >       metal:use-macro="here/main_template/macros/master"
> >       i18n:domain="plone">
> > <body>
> > 
> > <div metal:fill-slot="main" tal:define="results
> > python:container.portal_catalog(portal_type='Document',sort_on='Date',review_state='published',Subject='lead story');
> >                  the_result python:results[0].getObject()">
> >     <tal:main-macro metal:define-macro="main"
> >           tal:define="text python:the_result.CookedBody(stx_level=2);
> >                       len_text python:len(text.strip())">
> >         <div
> > metal:use-macro="here/document_actions/macros/document_actions">
> >             Document actions (print, sendto etc)
> >         </div>
> > 
> >         <h1 tal:content="the_result/Title" class="documentFirstHeading">
> >             Title or id
> >         </h1>
> > 
> >         <div metal:use-macro="the_result/document_byline/macros/byline">
> >             Get the byline - contains details about author and
> > modification date.
> >         </div>
> > 
> >         <p class="documentDescription"
> >            tal:content="the_result/Description"
> >            tal:condition="the_result/Description">
> >             News summary
> >         </p>
> > 
> >         <div class="newsImageContainer"
> >              tal:condition="the_result/image_mini|nothing">
> >             <a href="#"
> >                tal:attributes="href string:
> > $the_result/image/image_view_fullscreen">
> >                <img tal:replace="structure python:
> > the_result.tag(scale='mini', css_class='newsImage')" src="" alt="" />
> >             </a>
> >             <p class="discreet"
> >                   tal:content="the_result/getImageCaption">Image
> > Caption</p>
> >         </div>
> > 
> >         <p tal:condition="python: not len_text and is_editable"
> >            i18n:translate="no_body_text"
> >            class="discreet">
> >             This item does not have any body text, click the edit tab to
> > change it.
> >         </p>
> > 
> >         <div class="stx"
> >              tal:condition="text"
> >              tal:attributes="class python:test(here.Format() in
> > ('text/structured',
> >                                                    'text/x-rst', ),
> > 'stx', 'plain')">
> >             <div tal:replace="structure text" />
> >         </div>
> > 
> >         <div
> > metal:use-macro="the_result/document_relateditems/macros/relatedItems">
> >             Show related items if they exist
> >         </div>
> >         
> >         <div class="visualClear"
> > id="clear-space-after-relatedItems"></div>
> > 
> >     </tal:main-macro>
> > </div>
> > 
> > </body>
> > </html>  
> > 
> > 
> > _______________________________________________
> > Product-Developers mailing list
> > Product-Developers at lists.plone.org
> > http://lists.plone.org/mailman/listinfo/product-developers




More information about the Product-Developers mailing list