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.

Comments not showing up at times.

January 21, 2009 2:50pm

Subscribe [1]
  • #1 / Jan 21, 2009 2:50pm

    dookie

    19 posts

    I have a main articles template that displays comments at the bottom of a single entry article. Past articles are available by clicking the right hand nav. You can also access the first article from a teaser on the homepage. The comment always appears correctly when clicked from either of these spots. They use a {url_title_path} tag.

    The main menu uses {path} to get to the main section of the site. So when I click on articles from the main menu the page and content displays correctly but the comments do not.

    My guess is that in the cases that work it works because the links are wrapped around the title of the article and the article url is being appended to the end of the url due to the surrounding {exp:weblog:entries weblog"articles"} tag. And this is triggering the comments to relate to the article. 

    While the path variable only takes me to the template. Is there a way to append that url within a path variable or do I need to add the main entries tag with the url_title_path to make it work.

    Here is a link to the site.  http://www.ourrabbijesus.com/index.php

  • #2 / Jan 21, 2009 3:19pm

    Pascal Kriete

    2589 posts

    Derik,

    EE looks at the url to work out what content it’s supposed to serve.  For the pages that have a url_title in the url it’s pretty easy - it’s the entry with that url title.

    For your main templates it’s a little more difficult since they don’t have a url title that identifies a post.  What you need to do is get the entry id from the article you’re displaying and pass it on to the comment module by using the entry id parameter.  When this parameter is set EE ignores the url.

    One catch: you cannot nest the comments inside the weblog tag directly, so you will need to embed the comments & comment form and pass the id along as an embed variable.

    Does that make sense?

    Off topic: you may want to provide a permalink on the main template page so that users can bookmark the article.

  • #3 / Jan 22, 2009 1:48pm

    dookie

    19 posts

    I think I understand what you are saying.

    I have placed the comments and the form in an embedded template. And I understand what how to pass an entry_id. But I have one concern here. When you click the article menu item in the top it loads the articles page which pulls the latest articles entry. But the latest article that appears is always changing. So hardcoding the entry_id would not really work. But if I could dynamically pull the entry id of the latest article that would see to work. I’m not sure how to go about doing this.

    One other concern. If I do that is it going to mess with any of the other articles when I click on them in the right hand nav since the entry_id is pulling the latest article?

    Hopefully I am not too confusing.

  • #4 / Jan 22, 2009 2:16pm

    Pascal Kriete

    2589 posts

    You’re perfectly clear - I think 😉 .

    You’ll be pulling the entry_id out of the displayed article using the entry id variable.

    {exp:weblog:entries weblog="bla" limit="1" ... }
    
    <stuff>
    {title}{body}{custom_field}
    </stuff>
    
    {embed="articles/comments" article_id="{entry_id}"}
    
    {/exp:weblog:entries}

    Then in your embedded template you can use {embed:article_id} as the entry id on the comment tags.
    Does that make sense?

  • #5 / Jan 22, 2009 2:33pm

    dookie

    19 posts

    Thanks for all your help. It doesn’t seem to be working at the moment so I’ll post the code so you can see if I am missing something.


    The articles template:

    {embed="{my_embedded_template_group}/weblog_entry_comments" the_weblog="{my_weblog}" article_id="{entry_id}"}


    The embedded template:

    {exp:comment:entries weblog="{embed:the_weblog}" entry_id="{embed:article_id}"}
                      <div class="{switch="comment | commentalt"}">
                             <span class="count">{count}</span>
                  {url_or_email_as_author}<span class="pipe">|</span>{comment_date format="%F %d, %Y"}
                  {comment}
               </div>
            {/exp:comment:entries}
  • #6 / Jan 22, 2009 3:15pm

    Pascal Kriete

    2589 posts

    Can’t see anything off-hand.  Does it show the right id if you put {embed:article_id} outside the exp:comment tag?

  • #7 / Jan 22, 2009 3:29pm

    dookie

    19 posts

    I assume you mean like this;

    {exp:comment:entries weblog="{embed:the_weblog}" entry_id="{embed:article_id}"}
            {embed:article_id}
                      <div class="{switch="comment | commentalt"}">
                             <span class="count">{count}</span>
                  {url_or_email_as_author}<span class="pipe">|</span>{comment_date format="%F %d, %Y"}
                  {comment}
               </div>
            {/exp:comment:entries}

    Unfortunately it isn’t showing anything.

  • #8 / Jan 22, 2009 4:06pm

    Robin Sowell

    13255 posts

    Just for debug- put the article id outside of the comments tag a la:

    article id: {embed:article_id}
    {exp:comment:entries weblog="{embed:the_weblog}" entry_id="{embed:article_id}"}
    etc…
  • #9 / Jan 22, 2009 4:14pm

    dookie

    19 posts

    When I do this all I get is {entry_id} returned on the page.

  • #10 / Jan 22, 2009 8:34pm

    Greg Aker

    6022 posts

    dookie:

    Can you please show us the full code for your main template?

  • #11 / Jan 26, 2009 10:40am

    dookie

    19 posts

    Here is the main articles template.

    {assign_variable:my_weblog="articles"}
    {assign_variable:my_template_group="site"}
    {assign_variable:my_embedded_template_group="embeds"}
    
    {embed="embeds/html_head" my_page_title="{exp:weblog:entries weblog="articles" disable="categories|member-data|pagination|trackbacks" sort="asc" limit="1" }{title}{/exp:weblog:entries}"}
    
    <body id="internal">
    
    <div id="wrapper">
    
    {embed="{my_embedded_template_group}/main_nav" my_location="articles"}
    
    <div id="content">
        <div id="maincol">
            
              {exp:weblog:entries weblog="{my_weblog}" disable="categories|member-data|pagination|trackbacks" sort="asc" limit="1"}
              <h2>{title}</h2>
    <p>          <span class="author">Posted by {author} | </span><span class="date">{entry_date format='%F %j'} at {entry_date format='%h:%i %A'}</span></p>
    
    <p>            {page_body}<br />
                {/exp:weblog:entries}</p>
    
    <p>{embed="{my_embedded_template_group}/weblog_entry_comments" the_weblog="{my_weblog}" article_id="{entry_id}"}</p>
    
    <p></div><!-- closes maincolumn --><br />
            <br />
    <div id="secondarycol"><br />
                    <br />
               {embed="embeds/latest_internal" my_weblog="articles"}<br />
               {embed="embeds/weblog_categories" my_weblog="articles" my_current_cat="{category_url_title}"}<br />
               {embed="embeds/rss"}</p>
    
    <p></div><!-- closes secondarycol --><br />
        <br />
    </div><!-- closes content --><br />
    </div><!-- closes wrapper --><br />
    </body><br />
    </html>

    and here is the embedded comments and comment form template:

    <div id="comments">
    
    {site_url}images/interface/commentsstory.gif
            
            {exp:comment:entries weblog="{embed:the_weblog}" entry_id="{embed:article_id}"}
          
                      <div class="{switch="comment | commentalt"}">
                             <span class="count">{count}</span>
                  {url_or_email_as_author}<span class="pipe">|</span>{comment_date format="%F %d, %Y"}
                  {comment}
               </div>
            {/exp:comment:entries}
    
    </div><!-- close comment entries -->
    <div id="commentform">
          {site_url}images/interface/leaveacomment.gif
    
    
        {exp:comment:form}
            
                
                    Name:<br>
                    <input type="text" class="comment_textbox" name="name" value="{name}" size="60" />
                
                
                    Email:<br>
                    <input type="text" class="comment_textbox" name="email" value="{email}" size="60" />
                
                
                    URL:<br>
                    <input type="text" class="comment_textbox" name="url" value="{url}" size="60" />
                
            
            
                Comments:<br>
                <textarea name="comment" cols="50" rows="12">{comment}</textarea>
            
            {if logged_out}
                <input type="checkbox" class="check" name="save_info" value="yes" {save_info} /> Remember my personal information
            {/if}
            <input type="checkbox" class="check" name="notify_me" value="yes" {notify_me} /> Notify me of follow-up comments?
            {if captcha}
                
                    Enter this word:<br>
                    {captcha}
                
               
                
                    Here:<br>
                    <input type="text" name="captcha" value="" size="20" maxlength="20" style="width:140px;" />
                
            {/if}
            <input type="submit" class="submit_button" name="submit" value="Submit" /></p>
        {/exp:comment:form}
    </div>
  • #12 / Jan 26, 2009 1:31pm

    Robin Sowell

    13255 posts

    Aha- makes sense.  This bit:

    {embed="{my_embedded_template_group}/weblog_entry_comments" the_weblog="{my_weblog}" article_id="{entry_id}"}

    Needs to be inside the weblog tag- otherwise entry_id is just going to be a string- it’s not parsed.  Try shifting it up inside the weblog tag and let’s see where that gets us.

  • #13 / Jan 26, 2009 3:48pm

    dookie

    19 posts

    BoooyahHH! It works. Thanks so much for all your help. I’m not naturally a developer but I’m doing everything I can do get as familiar with this system as possible. Thanks for your patience with me. Your assistance on this forum is a definite plus when it comes to conquering the “fear factor” of working in such a scalable cms.

  • #14 / Jan 26, 2009 3:56pm

    Greg Aker

    6022 posts

    dookie:

    I’m glad Robin got you taken care of.  Closing this thread out, but don’t hesitate to post again if anything else comes up!

    -greg

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

ExpressionEngine News!

#eecms, #events, #releases