PDA

View Full Version : Need help with template please


Vincinzerei
08-16-2011, 08:22 AM
the old Vb 3.8 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 :
<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.

kh99
08-16-2011, 10:58 AM
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:

<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>

Vincinzerei
08-16-2011, 01:08 PM
k thanx a lot
Still not working but a Huge step further to make this Mod working again with vb4 :)

Vincinzerei
08-18-2011, 08:10 PM
Plugin:
(hookpoint: threadbit_display)

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
eval('$ddd_mod_reputation_score = "' . fetch_template('ddd_mod_reputation_score') . '";');


Template:

$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
$templater = vB_Template::create('ddd_mod_reputation_score');
$templater->register('threadbit_reputation', $threadbit_reputation);
$template_hook[threadbit_display] .= $templater->render(); somewhere to threadbit?

kh99
08-18-2011, 08:36 PM
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)?

Vincinzerei
08-18-2011, 08:51 PM
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

$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 {vb:raw reputitionvar}in threadbit_display the way to go?

kh99
08-18-2011, 09:48 PM
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:

{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?

Vincinzerei
08-19-2011, 07:01 AM
to avoid any missunderstandings:

instead of
eval('$ddd_mod_reputation_score = "' . fetch_template('ddd_mod_reputation_score') . '";');
i have to use
$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
<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
{vb:raw insert_reputation_var} there to get my output of the template shown there?
right? But it didnt work :(

kh99
08-19-2011, 08:02 AM
In this 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:

$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">...

Vincinzerei
08-19-2011, 10:19 AM
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
$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

<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
{vb:raw insert_reputation_var}

is this correct?

kh99
08-19-2011, 10:24 AM
Almost....

$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);


<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>

{vb:raw insert_reputation_var}



you also have {vb:raw comments} in your template, but I don't see that you've registered anything for that.

Vincinzerei
08-19-2011, 10:53 AM
ahja.. {vb:raw comments} = {vb:rawphrase comments}
have to look better and take more time it seems

Added it right next to <!-- threadstats -->
But still nothing hsown
just add {vb:rawphrase comments} in the threadbit template -> worked

as a test i tried something different:

$myplugin_output = "This is my plugin";

$templater = vB_Template::create('Testtemplate');
$templater->register('myplugin_output', $myplugin_output);
$templatevalues['insert_var1'] = $templater->render();
vB_Template::preRegister('threadbit', $templatevalues);

and a template with only
{vb:raw myplugin_output}
in it..
in threadbit i added
<li>{vb:rawphrase comments}:{vb:raw insert_var1} </li>
it worked great.

so i guess my problem is somewhere else. (maybe with the if condition)
thanx for the great help so far :)

edit: since iam not sure.. do i have to make a different register for "threadbit_reputation" since its nen Array?

Edit2: ha got it.. the if sequence is somehow "broken" for me. If i delete it, i see all comments. also all where the count is zero but hey.. getting better :)

edit3: Beginnerstyle programming: Just understood your comment about the threadbit_reputation_given. Now its working fine :)

Note to myself.. Learn to read englisch carefully ;)

kh99
08-19-2011, 11:21 AM
edit3: Beginnerstyle programming: Just understood your comment about the threadbit_reputation_given. Now its working fine :)

Great, I'm glad you got it working.

Note to myself.. Learn to read englisch carefully ;)

Sometimes the problem is that I haven't written it carefully. :)