We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32645
    • 377 Posts
    I have a ditto template which is used when outputting multiple articles.

    This is the structure;
    <!-- Article chunk -->
    <h2><span class="date">[*createdon:date=`%d/%m/%Y`*]</span><br />[+title+]</h2>
    
    [+phx:if=`[+tv_media+]`:isnot=``:then=`<img class="blackborder" src="[+tv_media+]" alt="[+title+]" />`+]
    [+phx:if=`[+tv_youtube:get_youtube+]`:isnot=``:then=`<div class="blackborder" style="width:581px;height:436px;">[[Youtube? &width=`581` &height=`436` &id=`[+tv_youtube:get_youtube+]`]]</div>`+]
    
    <div class="blog_article">
    	<div class="section_left box300_w">
    		[+content+]
    	</div>
    	<div class="section_right box300_w">
    		[+phx:if=`[+tv_relatedLinks+]`:isnot=``:then=`Related links:`+]
    		<div class="hide_ul_list">[+tv_relatedLinks+]</div>
    		<p class="txt_share">
    			Share: Put social bookmarks here.<br />
    <a href="[~[*id*]~]#top">^ Back to top</a>
    		</p>
    	</div>
    	<div class="clearfix"></div>
    </div><!--end:div-->
    


    When the user visits a single article, it is using the template associated with that page.

    However, I want to use the Ditto template instead.

    I have tried to make Ditto call the article chunk but how do you make it only display only 1 page (the page you, the user, are viewing)?

    Summary of problem:

    1) Multiple articles are displayed using a ditto chunk (see above for code)
    2) When a user clicks onto a single article returned by ditto, you are presented with that page’s template
    3) I want to use the ditto template, not the page’s template.

    I have attempted to use:

    [!Ditto? &parents=`[*parent*]` &documents=`[*id*]` &tpl=`articleChunk`!]
    


    But this always returns ’No documents found’.

    Is there a way to make single articles use the same ditto template as used by multiple articles?

    Thanks.
      • 26931
      • 2,314 Posts
      Hi worchyld,

      why don’t you use the Ditto-template code on your page template, no need to call the page content via Ditto on itself?!

      [+content+] would then need to be [*content*] on that page template for e.g.

      hope i undestood what you try to accomplish smiley
        • 32645
        • 377 Posts
        As I understand it, Ditto needs a chunk to output.

        Are you saying I should be creating a page that uses a template which is the same as the Ditto chunk?

        Does that not mean I am repeating myself -- I’ll have a ditto chunk and a page template, both of which need to be kept up to date.

        Ideally I just want to use one system, that way both the page and the ditto chunk reference the same template.

        I will attempt your idea on my offline version and post back
          • 32645
          • 377 Posts
          I have now resolved the problem.

          Step 1) Create articles, assign them a template (ie: SingleArticle)
          Step 2) Create ditto call to the chunk (ie: blogChunk)
          Step 3) On the SingleArticle template I made another ditto call,

          [!Ditto? &parents=`[*parent*]` &documents=`[*id*]` &display=`1` &total=`1` &tpl=`Blog_chunk` &debug=`1` !]
          


          For some reason this works fine, although in my past tests it didn’t work at all, and always returned "documents not found".

          I am now able to edit and use the same chunk for both multiple articles and single articles.

          This issue is now resolved.