Recent Topics

1 Oct 31, 2008 00:29    

My b2evolution Version: 2.x

I want to change the way single post previous and next links look in a skin. To do this I need to understand something more about the item_prevnext_links() function. Where (in which file) can I find said function?

2 Oct 31, 2008 01:58

Hi BenFranske,

If you're asking for it I presume it's not in index.main.php. Therefore I have reasons to believe your skin is split in multiple files. If so the single page is handled by single.main.php (Evopress and Simple Zen are examples of skins that have split files)
If this doesn't answer your question please name the skin you're using.

Good luck

3 Oct 31, 2008 02:55

I'm writing my own custom skin. I don't need to find where the function is called in the skin, what I'm looking for is where the function exists within the b2evo code so I can see what it's doing.

I did eventually find it in inc/items/model/_itemlist.class.php and found the answer I was looking for (if I could call separate functions to created the previous and next links with custom link text to load in a specific frame).

4 Oct 31, 2008 04:08

http://manual.b2evolution.net/Tag_item_prevnext_links

<?php
  // ------------------- PREV/NEXT POST LINKS (SINGLE POST MODE) -------------------
  item_prevnext_links( array(
     'block_start' => '<table class="prevnext_post"><tr>',
     'prev_start'  => '<td>',
     'prev_end'    => '</td>',
     'next_start'  => '<td class="right">',
     'next_end'    => '</td>',
     'block_end'   => '</tr></table>',
  ) );
  // ------------------------- END OF PREV/NEXT POST LINKS -------------------------
  ?>


According to the function in /inc/items/model/_itemlist.class.php you can add to this array:


    'prev_text' => '&laquo; $title$',
    'next_text' => '$title$ &raquo;',


and use $title$ as a variable according to this code. You can also check if $params holds some information you want to display.

Good luck

5 Oct 31, 2008 04:32

After playing with it for a bit I still haven't found what I'm looking for. Skinning b2evo is always a frustrating endeavor for me. I need to find functions which will return the URL and the title for the previous and next posts. I do not want a pre-formed link to be returned because I need to set the target within the link, just the url and the title.

b2evo always wants to do too much!

Any ideas?

6 Oct 31, 2008 12:58

Hi BenFranske,

If you spent a little more time with the code you realize how lovely it is. Because the prev/next function exists there are numerous functions that make up that result.
I suggest you try this:

$next_Item = get_prevnext_Item( 'next' );
$prev_Item = get_prevnext_Item( 'prev' );


That will return two Objects, basically arrays with all information on the Item. To view the Objects do:

pre_dump( $next_Item );


Place that in a skin and view the page in single post mode. It will display the Object as an array.
In that array look for the things you need: URL and title. On top of my head I don't remember how they are called but I guess it's permalink and title.
Then you can do something like:

<a href="<?php echo $next_Item[ 'permalink' ] ?>"><?php echo $next_Item[ 'title' ] ?></a>


or whatever.

I haven't tried any of this code, it's simply a description of 'how I'd tackle it'. Once you're at it you can ask any question in this forum.

Good luck

7 Oct 31, 2008 13:18

You may get away with:

$next_Item->get_permanent_url();
$next_Item->title;

8 Oct 31, 2008 21:45

Actually I was experimenting with it just as you suggested but I get an error about get_prevnext_Item() being an undefined function. I thought this might be because it's a function of a class so I tried running it as


$next_Item = $Item->get_prevnext_Item( 'next' );


but it also comes back as undefined. Any thoughts?

Thanks for your help!

9 Nov 01, 2008 00:25

Weird since the other function item_prevnext_links does work
Try to make an instance of the class:

$my_prev_next_object = new *add classname here*;


If need be you want to include the file.

Good luck


Form is loading...