uCoz Community uCoz Modules Additional Features Conditional Operators (<?if($VAR$)?>...<?else?>...<?endif?>) |
Conditional Operators |
Conditional operators for newbies and professionals. If you do not understand how conditional operators work and the information in the Control Panel is not enough for you, I will try to explain. First, you should believe, that it is very easy! Conditional operators are special codes-symbols, which can perform certain scenarios (scripts). You can create an absolutely new option on your site that is not provided in the Control Panel. First, you must understand and get used to the components of the script code. They are: <?if($code$)?> – it is some condition (code), which points to the operator whom and what we are dealing with. We can mentally replace it by the phrase «If there is»; <?else?> – it is the operator which will do what you say if the condition corresponds to the indicated ones. Replace it mentally by the phrase «If not»; <?endif?> – it is the end of the conditional operator, replace it mentally by «The end»;
Now let’s examine an easy example from the Control Panel: (from Page Editor) <?if($USER_LOGGED_IN$)?> Hello, $USERNAME$ <?else?> You are a GUEST. Please, register. <?endif?> In our language it means: «If there is an authorized user, then «Hello, his/her login!», if not, «Hello, guest!» and the end.» Now the details. What did we use? We said to <?if($code$)?> operator that our script is intended for saying hello to authorized users. We put the following code instead of $code$ - $USER_LOGGED_IN$ , i.e. we said «If there is an authorized user - <?if($USER_LOGGED_IN$)?>». Then the information, available only to authorized users, follows. At the same time, we may use conditions if they do not correspond to the indicated ones, in our example it is Guests. Therefore, after the information for registered users we enter the information for guests. We get Now we have just to close it. We can also exclude Guests and display information for registered users only. For this purpose we just do not use «If not». We get the following: <?if($USER_LOGGED_IN$)?> We are glad that you have registered! <?endif?> It means that only those who have logged in will see the phrase «We are glad that you have registered!». Any code, specified as working for a certain module, can be a condition for the work of operators. In our case (Page Editor), the following examples can be used: Login and logout: Days after registration: And so on.
Conditions for a script can be changed by means of additional capabilities, supported by the operators. They are «=», «>», «<» signs. If necessary, the equated conditions are separated by a vertical line. After the sign, you say to the operator to whom the whole script is directed. <?if($code$='condition')?> I can see this <?else?> And here I can see this <?endif?> Or <?if($code$='condition')?> The main thing is that I can see this <?endif?> Example: <?if($USER$='John')?> John, don’t forget to read e-mail every day. <?endif?> It means «If there are usernames and there is John among them (='John'), then this is to be displayed to him…» The same is with groups, names, gender, date etc. <?if($USER$='Mike' or $USER$='Lola')?> Mike and Lola, here is a secret link …. <?endif?> Groups: And so on. However, operators can work in each other. Example: <?if($USER_LOGGED_IN$)?> Hello $USER$! <?if($GROUP_ID$=3 || $GROUP_ID$=4)?> Don’t forget to click on the ads! <?endif?> <?else?> Please, register. <?endif?> The script is the following: «If there are logged-in users, then Hello, if there Administrators and Moderators among them, then add Click on ads, if there are unregistered users, we ask them to register, and the end.»
The main thing is that you must think well how to write a script, what codes to use and whom they will be directed to. You may write anything, uCoz is very flexible! Additional mini-info: I'm not active on the forum anymore. Please contact other forum staff.
|
ok thanks
Added (2010-10-28, 4:38 Am)
Code <?if($GROUP_ID$=1)?><img src="http://dl4uall.com/images/user.png" alt="User" border="0"><?endif?> <?if($GROUP_ID$=2)?><img src="http://dl4uall.com/images/author.png" alt="Author" border="0"><?endif?> <?if($GROUP_ID$=3)?><img src="http://dl4uall.com/images/mod.png" alt="Moderator" border="0"><?endif?> <?if($GROUP_ID$=4)?><img src="http://dl4uall.com/images/admin.png" alt="Administrator" border="0"><?endif?> <?if($GROUP_ID$=251)?><img src="http://dl4uall.com/images/regular.png" alt="Regular" border="0"><?endif?> <?if($GROUP_ID$=255)?><img src="http://dl4uall/images/guest.png" alt="Guest" border="0"><?endif?> Post edited by Zain - Thursday, 2010-10-28, 10:40 AM
|
I need help regarding this: how to make conditional operators for making each page title and meta tags unique...
How can I able to make each page title unique in every selection of Next Page. This is the Page Title code I used in the Ad Board: <title>$SITE_NAME$, Cebu house and lot, apartment, Cebu cars, Cebu real estate, Cebu jobs</title> This is the Page Selector highlighted in color yellow:
When you click number 2 of the Page Selector, the Page Title and Meta Tags I created remain the same. How can I make it unique in every page number? I find it difficult to understand ucoz conditional operators. Post edited by khen - Tuesday, 2010-12-28, 0:54 AM
|
How can I remove the span class of $CURRENT_PAGE$? The span class of the $CURRENT_PAGE$ in my website (http://www.affordablecebu.com) is currentPage79. I couldn't find this currentPage79 in my CSS.
I'm using $CURRENT_PAGE$ in order to create unique Page Titles and Meta Tags by adding $CURRENT_PAGE$ to them. But the problem is the span class currentPage79. The span class currentPage79 also appears in my Page Title. See the snapshot below on how it appears in my browser: How can I remove the span class currentPage79? Attachments:
2963494.jpg
(30.4 Kb)
|
khen, This is about both of your posts.
In order to display different titles in different pages of the entries list you should use conditional operators and the system code $CURRENT_PAGE$. This code displays current page number. If page number is 1 (e.g.) the first title should be used e.t.c The example of the condition can be: $SITE_NAME$, Cebu house and lot, apartment, Cebu cars, Cebu real estate, Cebu jobs The $CURRENT_PAGE$ code doesn’t display just the number (number of the current page). It displays the number in tags. |
Natashko, yes I want to use the $CURRENT_PAGE$ code but as what I've said above, there is this currentPage79 span class that distracts the $CURRENT_PAGE$ code. Please see Message # 68 (above).
How can I remove this currentPage79 span class? |
I want to make a option, that if any user tries to download games he needs to make 5 Posts?
Design no. 878 I made this : Quote <?if($POSTS$>5)?>Download Game<?endif?> Where should I put this? |
go to CP ---> Design ---> Design management(templates) ---> Online Games ----> page with entry full text and his comments
Find: Code <?if($LINK_PC$)?><td align="center" valign="top"><a href="$LINK_PC$"><img alt="" border="0" src="/.s/img/icon/download1.png" width="32" height="32"></a><div style="font-size:10px"><a style="text-decoration:none;" href="$LINK_PC$"><!--<s5393>-->Download for<!--</s>--> PC</a></div></td><?endif?> replace by: Code <?if($POSTS$>5)?><?if($LINK_PC$)?><td align="center" valign="top"><a href="$LINK_PC$"><img alt="" border="0" src="/.s/img/icon/download1.png" width="32" height="32"></a><div style="font-size:10px"><a style="text-decoration:none;" href="$LINK_PC$"><!--<s5393>-->Download for<!--</s>--> PC</a></div></td><?endif?><?else?> you need topost 5 posts first<?endif?> and this should work then , its better to use the code , like i did in the correct code , then the user will know thy need to post 5 posts first To busy building a passive income online ;)
|
SirDarknight, I have answered you here http://forum.ucoz.com/forum/6-12249-1#67836
|
Animorph, It says
Quote $CALENDAR$ code is used more than once. |
| |||