vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=242)
-   -   [HOW TO - vB4] Rendering templates and registering variables - a short guide (https://vborg.vbsupport.ru/showthread.php?t=228078)

ezak 04-09-2013 06:07 PM

Links and Download Modification is stoped supported because the author is died

I have problem in vb 4.2.0 can't register the variables

1- plugins
Name: Links and Downloads Manager - Add LDM to main vBulletin menu
Hooks: Prosses_templates_complete
code:
PHP Code:

    require_once(DIR '/includes/local_links_defns.php');

    if (
LDM_NAVBAR_LOCATION) {

        if (
defined('THIS_SCRIPT') and
                (
               
THIS_SCRIPT == LDM_LINKS_SCRIPT    or THIS_SCRIPT == 'local_links'
            
or THIS_SCRIPT == LDM_ACTION_SCRIPT    or THIS_SCRIPT == 'local_links_actions'
            
or THIS_SCRIPT == LDM_ADMIN_SCRIPT    or THIS_SCRIPT == 'local_links_admin'
            
or THIS_SCRIPT == LDM_SEARCH_SCRIPT    or THIS_SCRIPT == 'local_links_search'
                
)
            ) {
// Highlight ldm tab when in LDM - LDM code will create the actual tab and navbar
            
$vbulletin->options['selectednavtab'] = 'ldm';
        }
        else {
// Create the tab, no navbar needed
            
$templater vB_Template::create('links_navbar');
            
$templater->quickRegister(array(
                
'ldm_links_script'=>LDM_LINKS_SCRIPT,
                ));
            
$template_hook[LDM_NAVBAR_LOCATION] .= $templater->render();
        }

    } 


2- /includes/local_links_defns.php
PHP Code:

<?php

/* ===========================================================================*/
//
// This code is provided free on the basis that you do not claim that
// it is your own, sell it or use it as the basis for other products that you
// sell. But by all means extend it, modify it, upgrade it, correct it,
// suggest improvements, call me an idiot, etc.
//
// (c) 2004/10
// Andrew Dearing
// European Industrial Research Management Association
// www.eirma.org
//
// v3.0.2, 05.02.2010
// For VB4.0.x
// see changes.txt for history
// v1.00, 1.3.2004
//
/* ===========================================================================*/

// These definitions should correspond to the names of the main LDM scripts
// (held in the forums directory

define('LDM_LINKS_SCRIPT',        'local_links');
define('LDM_ACTION_SCRIPT',        'local_links_actions');
define('LDM_ADMIN_SCRIPT',        'local_links_admin');
define('LDM_RESIZE_SCRIPT',        'local_resize');
define('LDM_SEARCH_SCRIPT',        'local_links_search');
define('LDM_STREAM_SCRIPT',        'local_stream');

// This definition should be set to one of
//        'navtab_start', 'navtab_middle' or 'navtab_end'
// according to the location you want the entry to LDM to appear on the main vB navbar.
// Set the definition to the null strong '' if you do not want the entry to appear at all.

define('LDM_NAVBAR_LOCATION',    'navtab_middle');

?>

3- "links_navbar" template
PHP Code:

<vb:if condition="$vbulletin->options['selectednavtab'] == 'ldm'">

<
li class="selected">
    <
class="navtab" href="{vb:raw LDM_scripts.LDM_LINKS_SCRIPT}.php{vb:raw session.sessionurl_q}">{vb:rawphrase ldm_vbmenu_ldm}</a>
    <
ul class="floatcontainer">
    <
li class="popupmenu">
    <
a href="javascript://" class="popupctrl">{vb:rawphrase ll_menu_cat}</a>
    <
ul class="popupbody popuphover">
    <
li>
    <
a href="{vb:raw LDM_scripts.LDM_LINKS_SCRIPT}.php?{vb:raw session.sessionurl_q}">{vb:rawphrase ll_menu_home}</a>
    </
li>
<
vb:if condition="$show['ldm_add_category'] and $viewcatid>-2">
    <
li>
    <
a href="{vb:raw LDM_scripts.LDM_LINKS_SCRIPT}.php?{vb:raw session.sessionurl_q}action=addcat&amp;catid={vb:raw  viewcatid}">{vb:rawphrase ll_menu_addcat}</a>
    </
li>
</
vb:if>
<
vb:if condition="$show['ldm_edit_category'] and $viewcatid>0">
    <
li>
    <
a href="{vb:raw LDM_scripts.LDM_LINKS_SCRIPT}.php?{vb:raw session.sessionurl_q}action=editcat&amp;catid={vb:raw  viewcatid}">{vb:rawphrase ll_menu_editcat}</a></li>
</
vb:if>
    </
ul>
    </
li>

<
vb:if condition="$show['ldm_add_multi']">
    <
li class="popupmenu">
    <
a href="javascript://" class="popupctrl">{vb:rawphrase ll_entries}</a>
    <
ul class="popupbody popuphover">
    <
li id="ldm_navbar_addmulti">
    <
form action="{vb:raw LDM_scripts.LDM_LINKS_SCRIPT}.php" method="get">
    {
vb:rawphrase ll_menu_addmulti}
    <
input type="text" name="numadd" size="3" value="{vb:raw links_defaults.allow_add_multi}" />
    <
input type="hidden" name="action" value="addmultilink" />
    <
input type="hidden" name="catid" value="{vb:raw viewcatid}" />
    <
input type="submit" value="{vb:rawphrase ll_go}" name="submit" />
    </
form>
    </
li>
    </
ul>
    </
li>
<
vb:elseif condition="$show['ldm_add_link']" />
    <
li>
    <
a href="{vb:raw LDM_scripts.LDM_LINKS_SCRIPT}.php?{vb:raw session.sessionurl}action=addlink&amp;catid={vb:raw viewcatid}">
    {
vb:rawphrase ll_menu_addlink}
    </
a>
    </
li>
</
vb:if>

    <
li class="popupmenu">
    <
a href="javascript://" class="popupctrl">{vb:rawphrase ll_menu_show}</a>
    <
ul class="popupbody popuphover">
<
vb:if condition="$show['ldm_mark_link']">
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.FAVS_CAT}">{vb:rawphrase ll_menu_showfav}</a></li>
</
vb:if>

<
vb:if condition="$show['ldm_add_link']">
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.MY_CAT}">{vb:rawphrase ll_menu_showmyl}</a></li>
</
vb:if>

<
vb:if condition="$show['ldm_star_links']">
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.NOM_CAT}">{vb:rawphrase ll_menu_shownominate}</a></li>
<
vb:if condition="$show['ldm_view_nominations']">
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.CNOM_CAT}">{vb:rawphrase ll_menu_showcnominate}</a></li>
</
vb:if>
</
vb:if>

    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.HOT_CAT}">{vb:rawphrase ll_menu_showhot}</a></li>
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.NEW_CAT}">{vb:rawphrase ll_menu_shownew}</a></li>
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.NEW_RATE}">{vb:rawphrase ll_menu_shownewrating}</a></li>

    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.RND_CAT}">{vb:rawphrase ll_menu_showrnd}</a></li>

<
vb:if condition="$show['ldm_admin_links']">
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.AVL_CAT}">{vb:rawphrase ll_menu_showavl}</a></li>
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.HIDE_CAT}">{vb:rawphrase ll_menu_showhid}</a></li>
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.BRKN_CAT}">{vb:rawphrase ll_menu_showbrk}</a></li>
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.INVD_CAT}">{vb:rawphrase ll_menu_showinv}</a></li>
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.UPLD_CAT}">{vb:rawphrase ll_menu_showupl}</a></li>
<
vb:if condition="$links_defaults['featured_user_favs']">
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=find&amp;catid={vb:raw LDM_cats.FEAT_CAT}">{vb:rawphrase ll_menu_showfeat}</a></li>
</
vb:if>
</
vb:if>

    </
ul>
    </
li>

<
vb:if condition="$show['ldm_search_quick']">
    <
li class="popupmenu">
    <
a href="javascript://" class="popupctrl">{vb:rawphrase ll_menu_search}</a>
    <
ul class="popupbody popuphover">
    <
li id="ldm_navbar_search">
        <
form action="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php" method="get" id="ldm_search">
        {
vb:rawphrase ll_menu_search}
        <
input type="text" name="search" size="15" value="" />
        <
input type="submit" value="{vb:rawphrase ll_go}" name="submit" />
        <
input type="hidden" name="action" value="show" />
        <
input type="hidden" name="s" value="{vb:raw session.sessionhash}" />
        <
input type="hidden" name="literal" value="{vb:raw links_defaults.default_search_all}" />
        <
input type="hidden" name="desc"  value="<vb:if condition="$links_defaults['default_search_desc']">1<vb:else />0</vb:if>" />
        <
input type="hidden" name="keys"  value="<vb:if condition="$links_defaults['default_search_keys']">1<vb:else />0</vb:if>" />
        <
input type="hidden" name="ents"  value="<vb:if condition="$links_defaults['default_search_ents']">1<vb:else />0</vb:if>" />
        </
form>
        </
li>
        <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=search">{vb:rawphrase ll_advanced_search}</a></li>

        {
vb:raw ldm_mysavedsearch.menu}

        {
vb:raw ldm_myprofilesearch.menu}

    </
ul>
    </
li>
<
vb:elseif condition="$show['ldm_search_link']" />
    <
li><a href="{vb:raw LDM_scripts.LDM_SEARCH_SCRIPT}.php?{vb:raw session.sessionurl}action=search">{vb:rawphrase ll_menu_search}</a></li>
</
vb:if>

<
vb:if condition="$show['ldm_moderate_links']">
    <
li><a href="{vb:raw LDM_scripts.LDM_LINKS_SCRIPT}.php?{vb:raw session.sessionurl}action=mod">{vb:rawphrase ll_menu_mod}</a></li>
</
vb:if>

<
vb:if condition="$show['ldm_admin_links']">
    <
li><a href="{vb:raw LDM_scripts.LDM_ADMIN_SCRIPT}.php?{vb:raw session.sessionurl}action=admin">{vb:rawphrase ll_menu_admin} {vb:raw LDM_Version}</a></li>
</
vb:if>

    </
ul>
</
li>
<
vb:else />
<
li><class="navtab" href="{vb:raw ldm_links_script}.php{vb:raw session.sessionurl_q}">{vb:rawphrase ldm_vbmenu_ldm}</a></li>
</
vb:if> 


the problem Now , the variable is not registered like {vb:raw ldm_links_script} >> doesn't get the file name > thats make all links on the script ""when use the template" is invalid like this
http://localhost/vb/.php // Links and Download Main links
http://localhost/vb/.php?action=mod
http://localhost/vb/.php?action=admin



Please don't delete this post, the programer for this script will not help anymore, I searched alot to fix this problem but I can't fix it
BTW: this problem only available in vb4.2.0 , and not present in 4.1.x , don't know what is the reason

jimsflies 04-10-2013 02:14 PM

Hopefully someone can help here... I am beginning the daunting task of upgrading from vb3.8 to vb4. My forumhome uses a variable "$forumbitcounter" which is calculated in a plugin which contains the following code:

Code:

$forumbitcounter++;
What do I need to do to get this variable working on forumhome in vb4?

Lynne 04-10-2013 03:23 PM

Quote:

Originally Posted by jimsflies (Post 2415528)
Hopefully someone can help here... I am beginning the daunting task of upgrading from vb3.8 to vb4. My forumhome uses a variable "$forumbitcounter" which is calculated in a plugin which contains the following code:

Code:

$forumbitcounter++;
What do I need to do to get this variable working on forumhome in vb4?

You need to then preregister it for use in the FORUMHOME template (I assume that is the template you are using it in?)
PHP Code:

vB_Template::preRegister('FORUMHOME', array('forumbitcounter' => $forumbitcounter)); 


jimsflies 04-10-2013 04:08 PM

Quote:

Originally Posted by Lynne (Post 2415543)
You need to then preregister it for use in the FORUMHOME template (I assume that is the template you are using it in?)
PHP Code:

vB_Template::preRegister('FORUMHOME', array('forumbitcounter' => $forumbitcounter)); 


This is prolly a dumb question but was the major one I had reading the original post of this article... Does the registration code go in the forum home template or in a plugin?

Also the variable is actually used in the forumhome_forumbit_level1_post template so would it need to be registered there or would registering it in the containing template be okay?

Lynne 04-10-2013 04:43 PM

That code goes in the plugin right after your code that defines the variable. And if the variable is in the forumhome_forumbit_level1_post template template, then it needs to be:

PHP Code:

$forumbitcounter++;
vB_Template::preRegister('forumhome_forumbit_level1_post', array('forumbitcounter' => $forumbitcounter)); 


jimsflies 04-10-2013 04:55 PM

Thanks Lynne got it to work... I tried to like your post but got a message saying I have to like someone else's before liking any more of yours lol.

--------------- Added [DATE]1365617230[/DATE] at [TIME]1365617230[/TIME] ---------------

One other quick issue...I think this is due to the array (which I didn't have to use in vb3), the first value appears to be null, but needs to start with 1. How do I tell it to start with a value of 1?

Lynne 04-10-2013 10:34 PM

I'm not sure I understand... what are you using in the template for the variable? It should just be $variable or {vb:raw variable}

ezak 04-11-2013 05:20 AM

I found where is the problem, thanks :)

jimsflies 04-11-2013 07:37 PM

Quote:

Originally Posted by Lynne (Post 2415632)
I'm not sure I understand... what are you using in the template for the variable? It should just be $variable or {vb:raw variable}

I thought I had a fix yesterday, but it still isn't quite right. What I am doing is creating a counter for styling the forum home page. Using this counter in my template creates the alternating background shading and creates the two column layout as seen in my current vb3 site here: http://www.captivereefs.com/forum/forums.html

The problem seems to be on the first forumbitcount the value isn't 1 (I guess it is zero or is empty). Then the second forumbitcount is equal to 1 but should be 2.

Lynne 04-11-2013 10:05 PM

The variable needs to get preregistered for use in the template *after* is it defined, just like I had posted it above:

PHP Code:

$forumbitcounter++;
vB_Template::preRegister('forumhome_forumbit_level1_post', array('forumbitcounter' => $forumbitcounter)); 



All times are GMT. The time now is 01:40 AM.

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

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02683 seconds
  • Memory Usage 1,879KB
  • 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
  • (2)bbcode_code_printable
  • (7)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (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