On 9/17/2010 9:26 AM, Thomas Schrader wrote:
Hello again,

to clarify somethings of my previous post: The problem is that i always get 5 
times content of the first post of a page.
like in my previous post, my home.php looks like this:

<?php foreach($posts as $post): ?>
        <?php $theme->content($post, 'multiple'); ?>
  <?php endforeach; ?>

and I have a file "multiple.entry.php" which contains this for outputting posts 
of type entry:

<?php echo $post->title_out; ?>
<?php echo $post->content_out; ?>

I think I do have a problem with the correct using of the multiple.entry.php. 
Does anyone have an Idea where my mistake is?

This is a kind of complicated issue, although I think I have an idea of why this is doing this.

The 'multiple' argument to $theme->content($post, 'multiple') isn't a template name, it's a context.

When you pass a context, the context is prefixed to the possible templates used to display the content. So if you pass multiple for an entry type post, you get a series of fallback templates that include:

multiple.entry.php <-- context appended to content type
multiple.post.php <-- context appended to class of variable
entry.php <-- from the content type of the post
post.php <-- from the class of the variable storing the post
multiple.php <-- just the context

Note that passing a context of "multiple" would cause Habari to look for a template that is normally used for displaying multiple posts, which might not be desirable.

So what I think is happening is my passing "multiple" as the context argument, you're really telling Habari to display the multiple.php template, which normally would have the $posts variable it uses assigned internally from the request. Because it's being called through the content() pseudo-method on the Theme class, $post is getting reassigned to just the one post. Therefore, it's displaying the same post five times.

Suffice to say that you should remove the context value from the call to $theme->content(), or change it to something Habari doesn't use internally.

If doing that doesn't change your output drastically, then I'd next want to see what var_dump($posts) does just prior to your foreach loop in your home.php template.

Hope that helps.

Owen


--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/habari-users

Reply via email to