Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 08-16-2011, 08:22 AM
Vincinzerei Vincinzerei is offline
 
Join Date: Jun 2010
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Need help with template please

the old Vb 3.8 Code:

PHP Code:
<if condition="$show['reputationlink']">
<
span id="reputationmenu_$post[postid]"><a href="reputation.php?$session[sessionurl]p=$post[postid]rel="nofollow" id="reputation_$post[postid]"><img src="$stylevar[imgdir_button]/comment.gif" alt="<phrase 1="$post[username]">$vbphrase[add_to_xs_reputation]</phrase>" border="0" /></a></span>
<if 
condition="$show['popups']"><script type="text/javascript"vbrep_register("$post[postid]")</script></if>
</if> 


New Code vb4.1.x Code :
PHP Code:
<vb:if condition="{vb:raw show.reputationlink}">
<
span id="reputationmenu_{vb:raw post.postid}"><a href="reputation.php?{vb:raw session.sessionurl}p={vb:raw post.postid}" rel="nofollow" id="reputation_{vb:raw post.postid}"><img src="{vb:stylevar imgdir_button}/comment.gif" alt="<phrase 1="{vb:raw post.username}">{vb:phrase add_to_xs_reputation}</phrase>" border="2" /></a></span>
<
vb:if condition="{vb:raw show.popups}"><script type="text/javascript"vbrep_register("{vb:raw post.postid}")</script></vb:if>
</
vb:if> 
But i get an error and iam till now not able to find it :/

The Error is:
%1$s Wrong formated Syntax.
Reply With Quote
  #2  
Old 08-16-2011, 10:58 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The 'curly brace' {vb:raw variable} thing is only for displaying variables. In conditions you still need to use condition="$variable". So try putting back the original code in the two conditions, like:

Code:
<vb:if condition="$show['reputationlink']">
<span id="reputationmenu_{vb:raw post.postid}"><a href="reputation.php?{vb:raw session.sessionurl}p={vb:raw post.postid}" rel="nofollow" id="reputation_{vb:raw post.postid}"><img src="{vb:stylevar imgdir_button}/comment.gif" alt="<phrase 1="{vb:raw post.username}">{vb:phrase add_to_xs_reputation}</phrase>" border="2" /></a></span>
<vb:if condition="$show['popups']"><script type="text/javascript"> vbrep_register("{vb:raw post.postid}")</script></vb:if>
</vb:if>
Reply With Quote
  #3  
Old 08-16-2011, 01:08 PM
Vincinzerei Vincinzerei is offline
 
Join Date: Jun 2010
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

k thanx a lot
Still not working but a Huge step further to make this Mod working again with vb4
Reply With Quote
  #4  
Old 08-18-2011, 08:10 PM
Vincinzerei Vincinzerei is offline
 
Join Date: Jun 2010
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Plugin:
(hookpoint: threadbit_display)

PHP Code:
if($thread['threadid']) {
        
$thread_reputations_bit $db->query_read("
                SELECT threadid, COUNT(threadid) AS score, reputation
                FROM " 
TABLE_PREFIX "post AS post
                INNER JOIN " 
TABLE_PREFIX "reputation AS reputation ON (post.postid=reputation.postid)
                WHERE threadid = "
.$thread['threadid']."
                GROUP BY threadid,reputation"
        
);

        
$threadbit_reputation = array();

        
$threadbit_reputation['positive'] = 0;
        
$threadbit_reputation['neutral'] = 0;
        
$threadbit_reputation['negative'] = 0;

        
$show['threadbit_reputation_given'] = false;

        while (
$thread_reputation_bit=$db->fetch_array($thread_reputations_bit))
        {
                if(
$thread_reputation_bit['reputation'] > 0)
                {
                         
$threadbit_reputation['positive'] = $thread_reputation_bit['score'];
                } elseif(
$thread_reputation_bit['reputation'] == 0) {
                         
$threadbit_reputation['neutral'] = $thread_reputation_bit['score'];
                } else {
                         
$threadbit_reputation['negative'] = $thread_reputation_bit['score'];
                }
                
$show['threadbit_reputation_given'] = true;
        }

old eval
PHP Code:
eval('$ddd_mod_reputation_score = "' fetch_template('ddd_mod_reputation_score') . '";'); 

Template:

PHP Code:
$templater vB_Template::create('ddd_mod_reputation_score');
$templater->register('threadbit_reputation'$threadbit_reputation);  
$template_hook[threadbit_display] .= $templater->render();  

<
vb:if condition="$show['threadbit_reputation_given']">
<
span style="float:{vb:stylevar right}">{vb:rawphrase comments} <img src="{vb:stylevar imgdir_reputation}/reputation_pos.gif" border="0" />
{
vb:rawphrase threadbit_reputation.positive} <img src="{vb:stylevar imgdir_reputation}/reputation_balance.gif" border="0" /> 
{
vb:rawphrase threadbit_reputation.neutral} <img src="{vb:stylevar imgdir_reputation}/reputation_neg.gif" border="0" /> {vb:rawphrase threadbit_reputation.negative}</span>
</
vb:if> 
Still not working.. did i miss something out of the manual? Maybe add
PHP Code:
$templater vB_Template::create('ddd_mod_reputation_score');
$templater->register('threadbit_reputation'$threadbit_reputation);  
$template_hook[threadbit_display] .= $templater->render(); 
somewhere to threadbit?
Reply With Quote
  #5  
Old 08-18-2011, 08:36 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Your template seems to have vb:rawphrase in there a lot. Are those actually phrases, or should some of them maybe be vb:raw instead (to display the variable value)?
Reply With Quote
  #6  
Old 08-18-2011, 08:51 PM
Vincinzerei Vincinzerei is offline
 
Join Date: Jun 2010
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

the value (eg 1 2 or more) should be displayed.
i guess {vb:raw threadbit_reputation.positive} would be the right one in this case?

is
PHP Code:
$templater vB_Template::create('ddd_mod_reputation_score'); 
$templater->register('threadbit_reputation'$threadbit_reputation);   
$template_hook[threadbit_display] .= $templater->render();  
$templatevalues['reputitionvar'] = $templater->render();
vB_Template::preRegister('threadbit_display'$templatevalues); 
and
PHP Code:
{vb:raw reputitionvar
in threadbit_display the way to go?
Reply With Quote
  #7  
Old 08-18-2011, 09:48 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have to admit, I'm somewhat confused now. You're using both a templatehook and a variable? Or did you just forget to take out one of those? If there's a template hook where you want to insert your string, then you don't need to register a variable. Otherwise, you want to do what you have above (minus the templatehook line).

BTW, in my previous comment I was talking about these lines:

Code:
{vb:rawphrase threadbit_reputation.positive} <img src="{vb:stylevar imgdir_reputation}/reputation_balance.gif" border="0" />  
{vb:rawphrase threadbit_reputation.neutral}

should they really be phrases?
Reply With Quote
  #8  
Old 08-19-2011, 07:01 AM
Vincinzerei Vincinzerei is offline
 
Join Date: Jun 2010
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

to avoid any missunderstandings:

instead of
PHP Code:
eval('$ddd_mod_reputation_score = "' fetch_template('ddd_mod_reputation_score') . '";'); 
i have to use
PHP Code:
$templater vB_Template::create('ddd_mod_reputation_score');
    
$templater->register('threadbit_reputation_given'$threadbit_reputation_given);
    
$templater->register('$threadbit_reputation', $$threadbit_reputation);
$templatevalues['insert_reputation_var'] = $templater->render();
vB_Template::preRegister('FORUMHOME'$templatevalues); 
in the Plugin.

for the named template ddd_mod_reputation_score
i have to use
PHP Code:
<vb:if condition="$show['threadbit_reputation_given']">
<
span style="float:{vb:stylevar right}">{vb:raw comments} <img src="{vb:stylevar imgdir_reputation}/reputation_pos.gif" border="0" />
{
vb:raw threadbit_reputation.positive} <img src="{vb:stylevar imgdir_reputation}/reputation_balance.gif" border="0" /> 
{
vb:raw threadbit_reputation.neutral} <img src="{vb:stylevar imgdir_reputation}/reputation_neg.gif" border="0" /> {vb:raw threadbit_reputation.negative}</span>
</
vb:if> 
and to output it in the existing template (FORUMHOME or somewhere else where it has been registered)
i have to use
PHP Code:
{vb:raw insert_reputation_var
there to get my output of the template shown there?
right? But it didnt work
Reply With Quote
  #9  
Old 08-19-2011, 08:02 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In this code:

PHP Code:
$templater vB_Template::create('ddd_mod_reputation_score');
    
$templater->register('threadbit_reputation_given'$threadbit_reputation_given);
    
$templater->register('$threadbit_reputation', $$threadbit_reputation);
$templatevalues['insert_reputation_var'] = $templater->render();
vB_Template::preRegister('FORUMHOME'$templatevalues); 

When you register $threadbit_reputation, you don't want the $ in there. Also, if threadbit_reputation_given is only used in $show['threadbit_reputation_given'] you don't need to register it. So maybe try this:

PHP Code:
$templater vB_Template::create('ddd_mod_reputation_score');
    
$templater->register('threadbit_reputation'$threadbit_reputation);
$templatevalues['insert_reputation_var'] = $templater->render();
vB_Template::preRegister('FORUMHOME'$templatevalues); 

ETA: ...or maybe what you want is to leave in the registering of 'threadbit_reputation_given' and change the template to <vb:if condition="$threadbit_reputation_given">...
Reply With Quote
  #10  
Old 08-19-2011, 10:19 AM
Vincinzerei Vincinzerei is offline
 
Join Date: Jun 2010
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

iam a little bit new to this.. so i have problems to understand this:

If have:
a Plugin with Hookpint thread_display as shown in Post #4
there i add
PHP Code:
$templater vB_Template::create('ddd_mod_reputation_score');
    
$templater->register('threadbit_reputation_given'$threadbit_reputation_given);
    
$templater->register('threadbit_reputation', $$threadbit_reputation);
$templatevalues['insert_reputation_var'] = $templater->render();
vB_Template::preRegister('threadbit'$templatevalues); 
in my created template named ddd_mod_reputation_score i use
PHP Code:
<vb:if condition="threadbit_reputation_given">
<
span style="float:{vb:stylevar right}">{vb:raw comments} <img src="{vb:stylevar imgdir_reputation}/reputation_pos.gif" border="0" />
{
vb:raw threadbit_reputation.positive} <img src="{vb:stylevar imgdir_reputation}/reputation_balance.gif" border="0" /> 
{
vb:raw threadbit_reputation.neutral} <img src="{vb:stylevar imgdir_reputation}/reputation_neg.gif" border="0" /> {vb:raw threadbit_reputation.negative}</span>
</
vb:if> 
and in the stock template "threadbit" i add
PHP Code:
{vb:raw insert_reputation_var
is this correct?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:20 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.06394 seconds
  • Memory Usage 2,327KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (17)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete