Daily Archives: 7 Agosto, 2012

vBulletin 4: la sintassi condizionale per i template

Pubblicato da

vBulletin 4: la sintassi condizionale per i template

vBulletin 4: la sintassi condizionale per i template

vBulletin utilizza una sintassi proprietaria per permettere di personalizzare i template dei forum.
All’interno dei template per vBulletin si possono mostrare/posizionare elementi a seconda di determinate condizioni.
Ecco quelle più comuni

Se membri del forum:

<vb:if condition="$show['member']">Show this to members only</vb:if>

Se ospiti del forum:

<vb:if condition="$show['guest']">Show this to guest only</vb:if>

Se membri del gruppo

<vb:if condition="is_member_of($bbuserinfo, 1,2,3)">Show this to user group 
1, 2, and 3</vb:if>

Se utente specifico

<vb:if condition="$bbuserinfo['userid'] == 318713">Show this only to the 
member with the user id of 318713</vb:if>

Se non è utente specifico

<vb:if condition="$bbuserinfo['userid'] != 318713">Show this to every one 
but the member with the user id of 318713</vb:if>

Se moderatori

<vb:if condition="can_moderate()">Show this to all moderators</vb:if>

Se moderatore di un determinato forum

<vb:if condition="can_moderate($forum['x])">Show this if moderator is moderator 
of the forum with the id of x</vb:if>

Se moderatore del forum attuale

<vb:if condition="can_moderate($forum['forumid'])">Show this to the moderator 
of the current forum</vb:if>

Se l’id del forum è

<vb:if condition="$forum[forumid] == x">Show this if forum id is x</vb:if>

Se l’id del forum NON è

<vb:if condition="$forum[forumid] != x">Show this if forum id is not x</vb:if>

Se l’id del forum si trova tra questi id

<vb:if condition="in_array($forum['forumid'], array(1,2,3))">Show this to 
forum 1, 2 and 3</vb:if>

Se ci troviamo in questo script

<vb:if condition="THIS_SCRIPT != 'calendar'">Show this only on calendar.php</vb:if>

Se la variabile personalizzata è valorizzata

<vb:if condition="$customvar">Show this if $customvar is set</vb:if>

Se la variabile personalizzata è valorizzata ad un determinato valore

<vb:if condition="$customvar == blah">Show this if $customvar equals blah</vb:if>

Se la variabile personalizzata NON è valorizzata ad un determinato valore

<vb:if condition="$customvar != blah">Show this if $customvar does not equal 
blah</vb:if>

Esempio di utilizzo di else

<vb:if condition="$show['guest']">
Show this to only guest.
<vb:else />
Show this to all registered users
</vb:if>

Esempio di utilizzo con elseif

<vb:if condition="$show['guest']">
Show this to only guest.

<vb:elseif condition="is_member_of($bbuserinfo, 5,6)" />
Show this to user group 5 and 6 which is  mods and admins

<vb:else />
Show this to all registered users

</vb:if>

[via vBulletin.org Forum]