Recent Topics

custom class for individual posts

Started by on Nov 20, 2014 – Contents updated: Nov 27, 2014

Nov 20, 2014 01:00    

I'm working on a new skin, and I want to include a custom class for the posts on the page to take advantage of the css attribute=value tag. What I would like to do is set one post to be a certian width, the next two 50% and so on, but I'm not seeing how to insert the attribute in the code for specific posts. I hope that makes sense. >< I haven't seen a b2evo skin where someone has done this, but I've seen it in a lot of places and it's something I'd like to add. Any suggestions?

Nov 21, 2014 05:55

You can customise the appearance of individual posts by using the post

< div id="item_x" >

tag. Unless I am misunderstanding you...

Nov 23, 2014 01:31

What I'm wanting to do is for the actual code to format the first post with a specifc tag, the next two or so with a second tag, and the rest with a third tag. My assumption is that I would have the tags labeled in the template, with the command to pull just the first post and so on, but I'm not sure how to do that or even if that would be the best way to do it.

Nov 27, 2014 14:31

You mean you are looking to customize according to post order like post#1, post#2 ? See the attachment if that's what you are looking for.

If it's you can open your posts.main.php file and change:

PHP

while( $Item = & mainlist_get_item() )
{    // For each blog post:
    // ---------------------- ITEM BLOCK INCLUDED HERE ------------------------
    skin_include'_item_block.inc.php'array(
            'content_mode' => 'auto',        // 'auto' will auto select depending on $disp-detail
            'image_size'     =>    'fit-400x320',
        ) );
    // ----------------------------END ITEM BLOCK  ----------------------------

TO:

PHP

$pcounter 0;
while( $Item = & mainlist_get_item() )
{    // For each blog post:
    $pcounter++;
    $params =  array(
            'content_mode' => 'auto',        // 'auto' will auto select depending on $disp-detail
            'image_size'     =>    'fit-400x320',
        );
    // ---------------------- ITEM BLOCK INCLUDED HERE ------------------------
    include'_item_block.inc.php' );
    // ----------------------------END ITEM BLOCK  ----------------------------

And open your _item_block.inc.php and change:

PHP

<div id="<?php $Item->anchor_id() ?>" class="<?php $Item->div_classes$params ) ?>" lang="<?php $Item->lang() ?>">

TO:

PHP

<div id="<?php $Item->anchor_id() ?>" class="post_no<?php echo $pcounter;?> <?php $Item->div_classes$params ) ?>" lang="<?php $Item->lang() ?>">

Basically what you do is; using php include function istead of b2's skin_include function in your posts.main.php so that you can bump and pass the postcounter -$pcounter- to item.block.inc.php and echo the counter value in post class.


Form is loading...

powered by b2evolution – This forum is powered by b2evolution CMS, a complete engine for your website.