Strange Behavior on Post Rendering

Jan 26, 2011 at 1:27 AM

Hello,

I am revamping a graffiti 1.2 site and running into a hiccup on parent/child category posts with a custom category view.

The goal was to create a category view that would be just a listing of the Parent Categories...upon click-through to a child category it should render out a normal index.view of the posts in the child category.  All of this seems to work properly, but when I click on  the posts displayed in the child category it doesn't load.  The layout loads and no error is displayed...like the link just went to an empty post. 

Thought maybe I need to do a page rebuild, but then I created a postname.view for one of the posts and copied the index.view info into it.  Sure enough it displays just fine.

Any thoughts? 

Views are below


#if ($category.HasChildren == true)

#foreach ($child in $category.Children)
<div class="item">
    <h2><a href="$child.Url" title="$child.Name" rel="bookmark">$child.Name</a></h2>
</div>
#end

#elseif ($category.HasChildren == false)

#foreach($post in $posts)
<div class="item">
    <h2><a href="$post.Url" title="$post.Title" rel="bookmark">$post.Title</a></h2>
    #if ($post.ImageUrl.Length > 0)
    <img style="float: left; padding: 0px 10px 2px 0px;" src='$macros.Link($post.ImageUrl)' alt="$post.Title" />
    #end
    $post.Excerpt("<p>", "</p>" ,"", 600)
        <p style="{text-indent:5em;}"><a href="$post.Url">Read Full Post: $post.Title</a><p>
</div>
#end
#end

$macros.Pager("pagination")


and the INDEX.VIEW

#foreach($post in $posts)
<div class="item">
    <h2><a href="$post.Url" title="$post.Title" rel="bookmark">$post.Title</a></h2>
    #if ($post.ImageUrl.Length > 0)
    <img style="float: left; padding: 0px 10px 2px 0px;" src='$macros.Link($post.ImageUrl)' alt="$post.Title" />
    #end
    $post.Excerpt("<p>", "</p>" ,"", 600)
        <p style="{text-indent:5em;}"><a href="$post.Url">Read Full Post: $post.Title</a><p>
</div>
#end

$macros.Pager("pagination")

Jan 26, 2011 at 1:30 AM

and the POST.VIEW

<div class="item">
  <h2>
    $post.Title
  </h2>
  <p class="info ico ico-date">
    $macros.FormattedDate($post.CreatedOn) #if($post.taglist.Length > 0)-#end $macros.TagList($post.taglist, "")
  </p>

  $post.Body
</div>

<!-- / comment-list -->
#if($post.CommentCount > 0)

        <h2>$post.CommentCount comment(s) #if($post.EnableNewComments) so far #end</h2>

        #foreach($comment in $comments)
        #if ($comment.UserName == $post.UserName)
        <div class="comment owner" id="comment-$count">
        #else
        <div class="comment" id="comment-$count">
        #end
            <div class="comment-meta">
                <strong class="fn">$macros.CommentLink($comment)</strong> wrote on
                <a href="#comment-$comment.Id" title="Permanent link to this comment" rel="bookmark">$macros.FormattedDate($comment.Published)</a>
            </div>
            <div class="comment-body">
                $comment.Body
            </div>
        </div>
        #end
#end

#if($post.EnableNewComments)
<form action="$url" method="post" id="comment_form">
      <h2 class="subhead" id="respond">Post your comment</h2>
      <p></p>
      #if($isUser)
      <p>
        Logged in as $user.ProperName <a href="$urls.Logout">Logout</a>
      </p>
      #else
      <p>
        <input type="text" class="text" name="author" id="author" value="" tabindex="1" />
        <label for="author">Name</label>
      </p>
      <p>
        <input type="text" class="text"  name="email" id="email" value="" tabindex="2" />
        <label for="email">Mail</label>
      </p>
      <p>
        <input type="text" class="text" name="url" id="url" value="" tabindex="3" />
        <label for="url">Website</label>
      </p>
      #end
      <p>
        <textarea cols="15" rows="5" name="comment" id="comment" class="text" ></textarea>
      </p>
      <p>
        <img id="commentbutton" src='$macros.ThemeFile("i/btn_comment.png")' alt="Comment" onclick="Comments.submitComment('$urls.Ajax');" />
      </p>
      <p style="padding: 10px;">
        <span class="commentstatus" style="display:none;" id="comment_status"></span>
        <input type="hidden" name="comment_post_ID" value="$post.Id" />
      </p>
    </form>
<!-- / comment_form -->
#end

 

Coordinator
Jan 28, 2011 at 6:17 AM

It would be easier to guess the cause if I knew the names of all categories and theme files. And make sure you're at least on 1.3 Beta.

In your example, you may want [categoryname].view for each first level category, then [categoryname].childcategory.view where a list of posts is specified.

If you have a subcategory page that should look like the index.view, you could simply create a view at that deeper level like [categoryname].[subcategoryname].view which just contains $macros.LoadThemeView("index.view") so the content of index.view is still being used, not a duplicate copy of the contents of index.view. It should be no greater inconvenience that way.


Kevin explained it in this post as well, perhaps better than I can. http://graffiticms.codeplex.com/Thread/View.aspx?ThreadId=83067

Jan 28, 2011 at 8:43 PM

While not exactly the right fix to the problem, your suggestion and the other post you referenced led me to it.

The parent and child categories were rendering ok...what was actually missing (and I am still not sure why) was the post.view of posts in the child cats.  I added a copy of post.view renamed to parentcategory.post.view and then everything showed up perfectly.

Thanks for the help-

John