Error creating a plone template while following official training docs

Hi,
I’m trying to create a new plone template following these instructions: https://training.plone.org/5/theming/creating-customizing-templates.html#creating-a-new-plone-template. I’m getting an error on the line <div tal:repeat="item context/values". If I understand this correctly this mean that it’s trying to iterate through a collection, context/values, and assign each member to a temporary value “item”. It seems to be having trouble with “context/values”, but I’m not sure what context collection is.

I should note that this is from the official Plone vagrant box and I have customized it very little, save for creating a theme, also from the official docs (https://training.plone.org/5/theming/theme-package.html), which worked well. Almost all configuration changes that were recommended in the training were already there. Also I used the slider-images.pt file that already existed in themes/views, it just needed to be renamed. This is the first error I've encountered.

Thanks,
Gene

Full error:

  Traceback (innermost last):
   Module ZPublisher.Publish, line 138, in publish
   Module ZPublisher.mapply, line 77, in mapply
   Module ZPublisher.Publish, line 48, in call_object
   Module Products.Five.browser.metaconfigure, line 485, in __call__
   Module Products.Five.browser.pagetemplatefile, line 125, in __call__
   Module Products.Five.browser.pagetemplatefile, line 59, in __call__
   Module zope.pagetemplate.pagetemplate, line 132, in pt_render
   Module five.pt.engine, line 98, in __call__
   Module z3c.pt.pagetemplate, line 163, in render
   Module chameleon.zpt.template, line 261, in render
   Module chameleon.template, line 191, in render
   Module chameleon.template, line 171, in render
   Module d12f611b9ab9456774890d203c35ae39.py, line 120, in render
   Module five.pt.expressions, line 154, in __call__
   Module five.pt.expressions, line 126, in traverse
   Module zope.traversing.adapters, line 136, in traversePathElement
   __traceback_info__: (<Products.Five.metaclass.SimpleViewClass from /vagrant/plone/src/plonetheme.tango/src/plonetheme/tango/theme/views/slider-images.pt object at 0xb1d3d6cc>, 'values')
   Module zope.traversing.adapters, line 50, in traverse
   __traceback_info__: (<Products.Five.metaclass.SimpleViewClass from /vagrant/plone/src/plonetheme.tango/src/plonetheme/tango/theme/views/slider-images.pt object at 0xb1d3d6cc>, 'values', ())
   LocationError: (<Products.Five.metaclass.SimpleViewClass from /vagrant/plone/src/plonetheme.tango/src/plonetheme/tango/theme/views/slider-images.pt object at 0xb1d3d6cc>, 'values')
    - Expression: "context/values"
    - Filename:   ... .tango/src/plonetheme/tango/theme/views/slider-images.pt
    - Location:   (line 4: col 26)
    - Source:     <li tal:repeat="item context/values"
                                       ^^^^^^^^^^^^^^
    - Arguments:  repeat: {...} (0)
                  template: <ViewPageTemplateFile - at 0xb36b17ccL>
                  views: <ViewMapper - at 0xb1d1f40cL>
                  modules: <instance - at 0xb633f56cL>
                  args: <tuple - at 0xb747402cL>
                  here: <SimpleViewClass from /vagrant/plone/src/plonetheme.tango/src/plonetheme/tango/theme/views/slider-images.pt slider-images at 0xb1d3d6ccL>
                  user: <ImplicitAcquisitionWrapper - at 0xb358a324L>
                  nothing: <NoneType - at 0x83132e4>
                  container: <SimpleViewClass from /vagrant/plone/src/plonetheme.tango/src/plonetheme/tango/theme/views/slider-images.pt slider-images at 0xb1d3d6ccL>
                  request: <instance - at 0xb1d1566cL>
                  wrapped_repeat: <SafeMapping - at 0xb353593cL>
                  traverse_subpath: <list - at 0xb1d8f8ccL>
                  default: <object - at 0xb749aa18L>
                  loop: {...} (0)
                  context: <SimpleViewClass from /vagrant/plone/src/plonetheme.tango/src/plonetheme/tango/theme/views/slider-images.pt slider-images at 0xb1d3d6ccL>
                  view: <SimpleViewClass from /vagrant/plone/src/plonetheme.tango/src/plonetheme/tango/theme/views/slider-images.pt slider-images at 0xb1d3d26cL>
                  translate: <function translate at 0xb316ccdcL>
                  root: <ImplicitAcquisitionWrapper Zope at 0xb43a2cacL>
                  options: {...} (0)
                  target_language: <NoneType - at 0x83132e4>

Could you post your customized template?

Well, really, this isn't customized at all, it's just the one template that comes when you create a theme with mrbob. You just have to rename it it activate it. AFAIK it's the exact same one they want you to use in the tutorial.

Thanks, here's the template:

<div id="carousel-example-generic" class="carousel slide">
 <!-- Indicators -->
 <ol class="carousel-indicators hidden-xs">
     <li tal:repeat="item context/keys"
         data-target="#carousel-example-generic"
         data-slide-to="${python:repeat.item.index}"
         class="${python: repeat.item.start and 'active' or ''}"></li>
 </ol>

 <!-- Wrapper for slides -->
 <div class="carousel-inner">
     <div tal:repeat="item context/values"
         class="item ${python: repeat.item.start and 'active' or ''}">
         <img tal:define="scales item/@@images"
             tal:replace="structure python: scales.tag('image', scale='large', css_class='img-responsive img-full')" />
     </div>
 </div>

 <!-- Controls -->
 <a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
     <span class="icon-prev"></span>
 </a>
 <a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
     <span class="icon-next"></span>
 </a>
</div>

here's my theme folder structure

I figured out. It was a fundamental bit of misunderstanding on my part. When the tutorial says

To supply the images, we have to create a folder in Plone named slider-images and add some images there.

I took that to mean that I should create a folder in the file system and add images to it. Not that I should create a folder in the Plone app (TTW?), and upload images that way. http://localhost:8080/Plone/slider-images/@@slider-images is working for me now.

Thanks.

2 Likes