Results 1 to 12 of 12

Adding own META info to custom dynamic pages

This is a discussion on Adding own META info to custom dynamic pages within the General Discussion forums, part of the vBulletin SEO Discussion category; Hii.. The below code works perfect BUT please tell me how do I parse the template conditional and $vboptions[bbtitle] in ...

  1. #1
    Senior Member webwizzy's Avatar
    Real Name
    Vinayak
    Join Date
    Aug 2008
    Location
    India
    Posts
    257
    Liked
    0 times

    Adding own META info to custom dynamic pages

    Hii..

    The below code works perfect BUT please tell me how do I parse the template conditional and $vboptions[bbtitle] in there. Currently they display as it is.

    Hook: global_start

    PHP Code:
    if(THIS_SCRIPT == 'myscript')
    {
    $vbulletin->options['keywords'] = 'keyword1, keyword2, keyword3';

    $vbulletin->options['description'] = 'My custom page description for $vboptions[bbtitle]<if condition="$pagenumber>1"> - <phrase 1="$pagenumber">$vbphrase[page_x]</phrase></if>';

    Thank you

  2. #2
    Senior Member
    Real Name
    Michael Biddle
    Join Date
    Jan 2007
    Location
    Southern California
    Posts
    7,097
    Liked
    5 times
    You should be able to just put $vboptions[keywords] in the template that comes with that mod. Does it not work that way?
    The Forum Hosting - Forum Hosting from the Forum Experts

  3. #3
    Senior Member webwizzy's Avatar
    Real Name
    Vinayak
    Join Date
    Aug 2008
    Location
    India
    Posts
    257
    Liked
    0 times
    Quote Originally Posted by Michael Biddle View Post
    You should be able to just put $vboptions[keywords] in the template that comes with that mod. Does it not work that way?
    I didn' get you.

    $vboptions[keywords] is already included in all templates as we use $headinclude.

    The above code replaces this var with custom meta.

  4. #4
    Senior Member Shadab's Avatar
    Real Name
    Shadab
    Join Date
    Oct 2007
    Location
    Bhopal
    Posts
    821
    Liked
    0 times
    Blog Entries
    12
    Try this snippet :

    PHP Code:
    $vbulletin->options['description'] = 'My custom page description for ' .
        
    $vbulletin->options['bbtitle'] .
        ((
    $pagenumber 1) ? (' - Page ' $pagenumber) : '') ; 

  5. #5
    Senior Member Shadab's Avatar
    Real Name
    Shadab
    Join Date
    Oct 2007
    Location
    Bhopal
    Posts
    821
    Liked
    0 times
    Blog Entries
    12
    <!-- Double post -->

    Delete it. And Please fix the quick reply.

  6. #6
    Senior Member webwizzy's Avatar
    Real Name
    Vinayak
    Join Date
    Aug 2008
    Location
    India
    Posts
    257
    Liked
    0 times
    The pagenumber thing doesn't work.

    Isn't there a way to parse the template conditional/vars from the plugin?

    thanks

  7. #7
    Senior Member Shadab's Avatar
    Real Name
    Shadab
    Join Date
    Oct 2007
    Location
    Bhopal
    Posts
    821
    Liked
    0 times
    Blog Entries
    12
    You can try to add this line of code at the top of the plugin :

    PHP Code:
    $pagenumber intval($_GET['page']) ; 
    Note: I don't think using GPC vars like this would pose a security risk,
    as all INTVAL would return is an integer value, nothing else.
    Last edited by Shadab; 12-20-2008 at 11:09 AM. Reason: Using $_GET['page'] instead of $_GET['pagenumber']

  8. #8
    Senior Member webwizzy's Avatar
    Real Name
    Vinayak
    Join Date
    Aug 2008
    Location
    India
    Posts
    257
    Liked
    0 times
    that worked perfect, thanks

    So, first step done. Moving to second step, how do I make my script variables available in the plugin? So that I can use dynamic meta info from the database.

    I do not want to run the query to grab description as the query has already run through the script, is there a way to make the variables available in the plugin now?

    Thanks

  9. #9
    Senior Member Shadab's Avatar
    Real Name
    Shadab
    Join Date
    Oct 2007
    Location
    Bhopal
    Posts
    821
    Liked
    0 times
    Blog Entries
    12
    Depends on when your script is being executed.
    If you have used a generic vBulletin powered page format, like :

    PHP Code:
    <?php

    define
    ('THIS_SCRIPT''my_script');
    $globaltemplates = array( 'myscript' );

    require_once(
    './global.php');

    // Your custom script code here

    // Building the navbits

    // Printing the output

    ?>
    then I guess your script variables won't be available in that plugin. As the script is run 'after' the Global.php file has been included and the global start / complete hooks executed. Try this :

    Move your custom script to an external php file,
    and include() or require() it at the TOP of the plugin.

  10. #10
    Senior Member Shadab's Avatar
    Real Name
    Shadab
    Join Date
    Oct 2007
    Location
    Bhopal
    Posts
    821
    Liked
    0 times
    Blog Entries
    12
    ...
    Last edited by Shadab; 12-21-2008 at 03:53 AM. Reason: Double post.

  11. #11
    Senior Member webwizzy's Avatar
    Real Name
    Vinayak
    Join Date
    Aug 2008
    Location
    India
    Posts
    257
    Liked
    0 times
    Yes I am using a generic vb powered page like you described and my script variables are not available in the plugin.

    Move your custom script to an external php file,
    and include() or require() it at the TOP of the plugin.
    Can you give an example of it please. And can't there be some alternative for this, doing this just for META info looks really odd.

    And doing so, won't the external php be available globally throughout the site making it an extra load for every page.

    Thanks

  12. #12
    Senior Member Shadab's Avatar
    Real Name
    Shadab
    Join Date
    Oct 2007
    Location
    Bhopal
    Posts
    821
    Liked
    0 times
    Blog Entries
    12
    Plugin :
    PHP Code:

    if( THIS_SCRIPT == 'myscript' )
    {
        require(
    'includes/your_script.php');

        
    $pagenumber intval($_GET['page']) ;

        
    $vbulletin->options['keywords'] = $var1 'keyword1, keyword2' $var2 ;

        
    $vbulletin->options['description'] = 'My custom page description for ' .
            
    $vbulletin->options['bbtitle'] .
            ((
    $pagenumber 1) ? (' - Page ' $pagenumber) : '') ;
            

    your_script.php :
    PHP Code:
    <?php

    if( defined('THIS_SCRIPT') )
    {
        
        
    $query $vbulletin->db->query_read("Your query");
        
        while (( 
    $row $vbulletin->db->fetch_array($query) ))
        {
            
            
    $var1 $row['field1'];
            
    $var2 $row['field2'];
            
    // etc...    
        
    }
        
        
    $vbulletin->db->free_result($query);

    }

    ?>
    Haven't tested it.
    But I guess it should work as the variables would now be available and in scope.

Similar Threads

  1. Adding custom pages to sitemap
    By Johnny5 in forum General Discussion
    Replies: 2
    Last Post: 10-30-2008, 10:45 AM
  2. Custom Meta Info
    By woostar in forum vBSEO Features Archive
    Replies: 2
    Last Post: 04-14-2008, 07:19 AM
  3. Dynamic Meta Tags
    By jmurrayhead in forum Troubleshooting
    Replies: 2
    Last Post: 04-13-2008, 06:23 PM
  4. Sitemap pages, meta info
    By Dave Hybrid in forum General Discussion
    Replies: 4
    Last Post: 01-29-2008, 10:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •