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.
|
Animorph, Jan, I solved the problem,ty.
Added (2011-04-26, 6:56 Am) <?if($CATEGORY_ID$=3 or $CATEGORY_ID$=4)?> my text <?endif?> i wannt this text to be only in this two category on publisher,no in other.is it possible? |
Ronzky, where do you want to use it? Posts of what module do you mean?
|
Ronzky, you'll not be able to use this codes in all templates. This codes is working only in "User personal page" template.
|
How to put this forum link(when click here,direct go site forum) on my site"http://Freeforall.ucoz.com" top below my site banner .
Im post one other site image:im trying to make same. http://i54.tinypic.com/28kk9r8.jpg |
Helpinghand, how is this at all related to uCoz's conditional operators? Next time please remember to post your threads in the correct forums.
As for your issue you need to insert the image under the site banner within a hyperlink. This will most easily be done using the HTML editor mode. Hope this helps, Jack of all trades in development, design, strategy.
Working as a Support Engineer. Been here for 13 years and counting. |
sir.Im new here,register yesterday,where put this..im confuse......
Paradox..Thanks for your sugeetion.....Great site realy helpfull.im trying make this but not succes,can u tell me where find one video tutial,that iam success to make this.pls....... |
Helpinghand, okay. You would put this code:
Quote <a href="http://freeforall.ucoz.com/forum"><img src="image link here"></a> under the HTML for the page header. You will find the pages HTML by opening Control Panel > Design Customisation > Top part of website. I have answered you in your other thread about the video tutorials. Please do try at least to post your threads in the correct forums. Hope this helps, Jack of all trades in development, design, strategy.
Working as a Support Engineer. Been here for 13 years and counting. |
Paradox,Thanks..but not working for me.
im post my site code below,pls see......... My site "top part of the website" full code : sir,Im trying to make this type...... my site banner pic. Post edited by Helpinghand - Monday, 2011-06-27, 6:04 PM
|
| |||