Pascal Posted June 9, 2013 Share Posted June 9, 2013 Hi! I am working on customizing the Blog Profile. I wonder if it is possible to have different markup for individual posts and the paginated post list. I edited the markup/post.php for the view of an individual post. However, in the post list, several elements should not be shown. For example, I need the headline of the posts in the blog's landing page to have different classes than when viewing an individual post. First I thought this was because markup/posts.php includes markup/post.php. So I created markup/post_list.php and included it in markup/post.php. However then a single blog post was also rendered with the markup from markup/post_list.php. I don't know if there is any easy solution, I can't wrap my head around how some of these files are connected. Can anyone help me on this one? Edit: Got it! Just count the elements of the $posts array and generate different markup if it is > 1. <?php $pagecount = count($posts); if($pagecount == 1) { $parentpage = $page->parent->url; echo "<div class='arrow'><a href='$parentpage'>←</a></div>"; } ?> However, feel free to suggest anything easier or more elegant. Link to comment Share on other sites More sharing options...
Pascal Posted June 11, 2013 Author Share Posted June 11, 2013 Well, I forgot that this would not work if there is only one post to display in the list. Does anyone have an idea? Link to comment Share on other sites More sharing options...
Wanze Posted June 11, 2013 Share Posted June 11, 2013 Hi Pascal, The function renderPosts which renders one or multiple posts, takes an argument $small. When small is set to true, the blog profile hides for example the comments and other things. So I suggest that you edit /site/templates/markup/post.php and give your classes based on the $small. $small is true when rendering multiple post and false when rendering one post (detail-view). // 'post-list' class when $small is true, otherwise 'post-detail' $class = ($small) ? 'post-list' : 'post'; echo "<div class='post {$class}'>"; 1 Link to comment Share on other sites More sharing options...
Pascal Posted June 11, 2013 Author Share Posted June 11, 2013 Thanks for the hint. However, the argument $small seems to refer to the abbreviated lists like category views, not the paginated list of all articles (the "standard" blog view). I did this and it doesn't have any effect: <?php foreach($posts as $page) { $pagecount = count($posts); if(!$small) { include('./post.php'); } else { include('./post-list.php'); } } ?> While this works, albeit only if there are multiple posts on a paginated page: <?php foreach($posts as $page) { $pagecount = count($posts); if($pagecount == 1) { include('./post.php'); } else { include('./post-list.php'); } } ?> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now