vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Adding <link rel="prev" etc (https://vborg.vbsupport.ru/showthread.php?t=306081)

dethfire 12-19-2013 09:40 PM

Adding <link rel="prev" etc
 
Has anyone been successful in adding <link rel="prev and "next" tags in their threads? I see most current software is doing this regardless of physical pagination.

Ameise 01-06-2015 09:06 PM

I try it with the
Code:

<if condition="$show['next']"><link rel="next" href="$address$address2&amp;page=$nextpage</if>
<if condition="$show['prev']"><link rel="prev" href="$address$address2<if condition="$prevpage != 1">&amp;page=$prevpage</if></if>

but the hook is not active in the headinclude

ozzy47 01-06-2015 09:36 PM

Thanks for posting the suggestion, even though the question was asked thirteen months ago. :p

Ameise 01-07-2015 08:42 AM

But is not solved.
I try something in the function.php by line 2405 to add the headinclude, but it doesnt work.

ozzy47 01-07-2015 09:55 AM

1 Attachment(s)
Just to be clear, you are trying too add something like in the attached screenshot?

kh99 01-07-2015 02:13 PM

Quote:

Originally Posted by Ameise (Post 2530815)
I try it with the
Code:

<if condition="$show['next']"><link rel="next" href="$address$address2&amp;page=$nextpage</if>
<if condition="$show['prev']"><link rel="prev" href="$address$address2<if condition="$prevpage != 1">&amp;page=$prevpage</if></if>

but the hook is not active in the headinclude

Yeah, the problem is that the headinclude template is rendered before any of the page values are calculated. What you might be able to do is a str_replace on the $header variable at some later time. I'd have to know your exact version (and have that source available) to know what's around line 2405 of function.php. But maybe you can use a plugin at hook locaton pagenav_complete to add them, with code something like:
PHP Code:

global $headinclude;
if (
$show['next'])
{
   
$headinclude .= "<link rel=\"next\" href=\"{$address}{$address2}&amp;page={$nextpage}\"/>\n";
}
if (
$show['prev'])
{
   
$headinclude .= "<link rel=\"prev\" href=\"{$address}{$address2}&amp;page={$prevpage}\"/>\n";



Edit: (I replaced the above code - I copied the wrong version).

Ameise 01-15-2015 09:32 AM

Works fine with this code:
Code:

if ($pagenumber > 1)
        {
        global $headinclude;
                $prevpage = $pagenumber - 1;
                $prevnumbers = fetch_start_end_total_array($prevpage, $perpage, $results);
                $show['prev'] = true;
                $headinclude .= "<link rel=\"prev\" href=\"{$address}&amp;page={$prevpage}\">\n";
        }
        if ($pagenumber < $totalpages)
        {
        global $headinclude;
                $nextpage = $pagenumber + 1;
                $nextnumbers = fetch_start_end_total_array($nextpage, $perpage, $results);
                $show['next'] = true;
                $headinclude .= "<link rel=\"next\" href=\"{$address}&amp;page={$nextpage}\">\n";
        }


hilaryl 01-19-2015 01:17 AM

How would you do this without making changes to functions.php?

Is there a way to get the variables you need by using a plugin?

Been stumped on this one for a while.

Cheers,
hilaryl

kodbg 03-12-2015 11:32 AM

So, is there a solution for adding prev / next in head?

PP - Sorry, the code above works fine - thank you

hilaryl 04-01-2015 09:59 PM

Quote:

Originally Posted by Ameise (Post 2532644)
Works fine with this code:
Code:

if ($pagenumber > 1)
        {
        global $headinclude;
                $prevpage = $pagenumber - 1;
                $prevnumbers = fetch_start_end_total_array($prevpage, $perpage, $results);
                $show['prev'] = true;
                $headinclude .= "<link rel=\"prev\" href=\"{$address}&amp;page={$prevpage}\">\n";
        }
        if ($pagenumber < $totalpages)
        {
        global $headinclude;
                $nextpage = $pagenumber + 1;
                $nextnumbers = fetch_start_end_total_array($nextpage, $perpage, $results);
                $show['next'] = true;
                $headinclude .= "<link rel=\"next\" href=\"{$address}&amp;page={$nextpage}\">\n";
        }


Have added this as a plugin - and pushing the links to page so that's bloody awesome.

Have been looking for a solution to this issue for a while now - and this is perfect. Had to tweak a few things to allow for my URL structure - but it's working perfectly now.

Also added in an if statement to cater for being on page 2 and not including a 'page=1' to the previous page.

THANK YOU VERY MUCH!!


All times are GMT. The time now is 09:38 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01223 seconds
  • Memory Usage 1,749KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (1)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete