ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Single channel entry template issues

March 25, 2012 3:56am

Subscribe [3]
  • #1 / Mar 25, 2012 3:56am

    Hench

    3 posts

    Hi all,

    I’ve recently started using Expression Engine having come from a Wordpress-as-CMS background. Loving it so far, the flexibility and the way it keeps out of your way in terms of front end is fantastic - I’ve made the switch for good.

    Now, I’ve got a couple of issues which I’ve tried hard to find solutions to by searching, but haven’t worked it out. I’m building a site which has a blog, and the blog entries have a single entry template with comments. Ordinary stuff.

    This is all working fine but for a few things where I assume I’ve made a basic error.

    The content etc is fine, and it’s pulling the right comments for that entry.

    First issue: comment email addresses are echoing as the admin email. Here’s my code:

    <section>
                   {exp:channel:entries channel="blog" limit="1"}
                   <article>
                         <hgroup><h1>{title}</h1></hgroup>
                         {edit_this}
                         <span class="articleMeta">{entry_date format="%d %M %Y"} / in {categories backspace="2"}<a href="http://{path=">{category_name}</a>, {/categories}</span>
                         {blogContent}
                         {social}
                      
                   </article>
                   <article>
                      {comment_list}
                      {comment_form}
                   </article>
                   {/exp:channel:entries}
                </section>

    The comment form and list snippets are pretty standard. I won’t show the form, but here’s the code for rendering:

    {exp:comment:entries}
        {exp:ce_gravatar:single email=
        <span class="rightFloat articleMeta">{comment_date format="%d %M %Y at %g:%i%a"}</span>
        <h3>{name} said:</h3>
    <p>    {comment}<br />
        {email}<br />
        <hr ><br />
    {/exp:comment:entries}

    as you can see i’m using the gravatar plugin. The final {email} tag is there so I can see what’s being output - in each comment, it’s the admin/global email.

    Not sure what’s wrong here, any help appreciated.


    The second issue is I am having a hard time understanding why I can’t get a list of posts to display in a sidebar. I’m calling them like this (below the above code in the template):

    <section>          
                      {exp:channel:entries channel="blog" limit="4"}
                      <li>
                         <article>
                            <hgroup>
                               <h4><a href="http://{url_title_path=blog}">{title}</a></h4>
    <p>                        </hgroup><br />
                            {exp:word_limit total="22"}<br />
                               {blogContent}<br />
                            {/exp:word_limit}<br />
                            {comment_total} Comments / <a href="http://{url_title_path=blog}">Read more</a><br />
                         </article><br />
                      </li><br />
                      {/exp:channel:entries}<br />
                </section>


    I’m assuming I’ve got a fundamental way of working with templates mixed up here. I have to this point got on just fine with calling channel entries like so, but this doesn’t seem to work in these single entry templates, so I’d like to find out why before I go to far with the rest of my integration and find out I’ve gone astray!

    Much of the rest of the site is quite simple, but there are some more tricky things like a store and an ajax product browser, so I’d like to be put straight before I get to those.

    Cheers for any help, much appreciated.

    Dan

     

     

  • #2 / Mar 25, 2012 7:45am

    Rob Games

    38 posts

    Hi Dan,

    Issue 1:
    Try putting the comments outside of the channel:entries tag. It could be that the {email} variable is trying to parse the posts authors’ email rather than the comment author. An example below:

    <section>
                   <article>
          {exp:channel:entries channel="blog" limit="1"}
                        <hgroup><h1>{title}</h1></hgroup>
                        {edit_this}
                        <span class="articleMeta">{entry_date format="%d %M %Y"} / in {categories backspace="2"}<a href="http://{path=">{category_name}</a>, {/categories}</span>
                        {blogContent}
                        {social}
                        {/exp:channel:entries}
                   </article>
                   <article>
                      {comment_list}
                      {comment_form}
                   </article>
                </section>

    Issue 2
    Try adding the parameter dynamic=“off” - Like so:

    {exp:channel:entries channel="blog" limit="4" dynamic="off"}

    —-

    In regards to a store, EE has lot’s of off the shelf, really flexible solutions. Which one you choose is entirely down to your requirements. To name a few:

    - http://devot-ee.com/add-ons/expresso-store
    - http://devot-ee.com/add-ons/cartthrob-2
    - http://devot-ee.com/add-ons/brilliantretail

    This tutorial below shows how to use Solspace’s supersearch module, with Malsup’s Jquery form plugin, to create an ajax search facility, which could be used to create an ajax product browser. http://www.reusserdesign.com/blog/creating-an-ajax-filter-using-solspace-super-search/

    Hope this helps.

     

  • #3 / Mar 25, 2012 9:10pm

    Boyink!

    5011 posts

    A bit of an OCD moment - but “off” is deprecated for EE2.  Use “dynamic=“no” instead..😉

  • #4 / Mar 26, 2012 4:08am

    Rob Games

    38 posts

    Thanks Boyink!, well spotted 😊

  • #5 / Mar 26, 2012 4:09am

    Hench

    3 posts

    That really helped, thank you Rob.

    I came across dynamic=“no”, but thought it would be used the other way around for some reason! I think I get it now. The comments ouside the channel:entries also seemed a little counter-intuitive until I understood the first point and how EE works.

    With all that in mind, do I even need to wrap the entry itself in the channel tag? ie: can I completely remove this, and if not - why, when it doesn’t affect the comments? -

    {exp:channel:entries channel="blog" limit="1"}

    Thanks for your input too Boyink, i’ll swap over the “off” state that I put in earlier for “no”.

  • #6 / Mar 26, 2012 8:18am

    Boyink!

    5011 posts

    Here’s a little screencast I put together to explain the dynamic property:

    http://www.train-ee.com/courseware/free-tutorials/comments/dynamic-off-explained/

    Keep in mind it was recorded for EE1 so does use dynamic=“off” yet…;)

  • #7 / Mar 26, 2012 8:22am

    Hench

    3 posts

    One more question to hopefully set me on my way quite nicely.

    I have a structure like so:

    (root)
    - Articles
    —blog items (channel)
    —essays (channel)
    —q&a (channel

    All working nicely, including the single-view pages. But I would like to have my q&a (“qanda” is the channel) work a little differently, so instead of the single entry living at /articles/qanda/entry-title, it would live at /articles/qanda/answers/entry-title - so there is a child template beneath “qanda” called “answers”.

    Is this possible?

    Thanks again.

  • #8 / Mar 26, 2012 8:27am

    Boyink!

    5011 posts

    There is no notion of a “child template” in EE.  You get templates organized into groups, and that’s it.

    However you could have a qanda template, but link to it with the /answers/ segment in the URL (you’d have to create your own links to get it in there vs. using straight linking variables), then have the channel:entries tag on the qanda template running in dynamic=“no” mode, with the url_title=”{segment_4}” or url_title=”{last_segment}”.

    However usually developers want to remove additional non-useful elements of the URL to make the urls more concise, rather than add them in.

  • #9 / Mar 26, 2012 8:33am

    Rob Games

    38 posts

    Hi Hench,

    Whilst it is not possible to nest a template group within a parent template group. Within a template you can use EE conditionals and url_segment’s to achieve a similar effect.

    Take for example the code below on the “qanda” template.

    {if segment_3 == ""}
    
    {!-- Code will be rendered if the URI is /articles/qanda/--}
    
    {/if}
    
    {if segment_4 != ""}
    
    {!-- Code will be rendered if the URI is /articles/qanda/answers/entry-title --}
    {exp:channel:entries channel="q&a" limit="1" dynamic="no" url_title="{segment_4}"}
    
    {!-- If no entry exists redirect to a 404 page --}
    {if no_results}{redirect="404"}{/if}
    
    <h1>{title}</h1>
    {body}
     
    {/exp:channel:entries}
    
    
    {/if}

    Not the most elegant solution, but should achieve what you want to do.

  • #10 / Mar 26, 2012 8:51am

    Hench

    3 posts

    Alright. That’s helpful. Boyink I understand what you are saying about keeping the URL concise, and perhaps you’re right.

    Regardless, now I know! :D

    Really appreciate the help guys, thank you.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases