conditionals using 2 fields ?

Discuss news styles, css code, and other Coranto customizations in here...the possibilities are endless, so have at it!

Moderator: Spunkmeyer

conditionals using 2 fields ?

Postby davidarthurs » Tue Jul 25, 2006 2:03 pm

Field: TotalItemCounter gives me the count for each sliced page

and Field: TotalPageMax gives me the count for the last page

so how do I write if Field: TotalItemCounter = Field: TotalPageMax then do something ?

I've tried

<code>
<If: Field: TotalItemCounter> == <Field: TotalPageMax>do this</If> </code>
but no joy.
davidarthurs
 
Posts: 23
Joined: Wed Feb 25, 2004 3:45 pm

Postby Dale Ray » Wed Jul 26, 2006 2:06 am

try this:

Code: Select all
<PerlCode>
if ($TotalItemCounter == $TotalPageMax) {
</PerlCode>
do something here
</If>


Use == for numeric comparison and eq for strings.

Try reading Using Item Counters in Coranto Styles. It may not be specific to your needs, but there is some code explained in it.
Dale Ray
User avatar
Dale Ray
 
Posts: 1001
Joined: Sun Jan 19, 2003 6:02 pm
Location: NW Indiana

Postby davidarthurs » Wed Jul 26, 2006 9:24 am

Worked a treat. Thanks a mill mate.
davidarthurs
 
Posts: 23
Joined: Wed Feb 25, 2004 3:45 pm

Postby Prine » Tue Oct 03, 2006 5:04 pm

trying to do something similar, this what i came up with (im fine with PHP coding, but new to PERL)


Code: Select all
<If: Field: CustomField_image eq " ">
 <Field:CustomField_image> eq "news"
 </If>



is this all wrong?
Prine
 
Posts: 7
Joined: Wed Apr 12, 2006 12:16 pm

Postby Parahead » Tue Oct 03, 2006 5:30 pm

Prine wrote:trying to do something similar, this what i came up with (im fine with PHP coding, but new to PERL)
Code: Select all
<If: Field: CustomField_image eq " ">
 <Field:CustomField_image> eq "news"
 </If>

is this all wrong?
The original question was how to compare two variables/fields with each other, which is not the same as what you have done. The code provided by Dale Ray did solve the initial question.

I guess what you try to achive (looking at your example) is to test two individual fields against static values and if both match, do something? If that is the case, it do contain some errors, I *think* this is what you want?
Code: Select all
<If: Field: CustomField_image eq " ">
   <If: Field:CustomField_image eq "news">
    Write something if both tests go through...
   </If>
</If>


BTW, the code is not Perl, it is a Coranto specific implementation of how to use conditionals. Dale Rays if-statement is Perl.
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby SrNupsen » Tue Oct 03, 2006 8:20 pm

I think he wants to test whether CustomField_image is blank (""), and then, if that is the case, set CustomField_image to "news".

Your two conditionals seem rather pointless to me, Parahead, since in no case the field value can at the same time be equal to both " " and "news".

SrNupsen
- definitely no perl man
-----------------------------------------------------------------------------------------------------
Coranto is free software. I am available for custom work or troubleshooting.

http://www.sundaune.no - transkripsjon, webdesign, nettsider, tekstbyrå
http://www.vagbladet.no - satire, politikk, kultur, sport, nettavis
-----------------------------------------------------------------------------------------------------
SrNupsen
 
Posts: 2229
Joined: Tue Jan 09, 2007 6:46 pm
Location: Nesodden, outside Oslo, Norway

Postby Dale Ray » Tue Oct 03, 2006 10:35 pm

Code: Select all
<perlCode>if ($CustomField_image eq "") {
 $CustomField_image = "news";
}
</PerlCode>


Is the above what you want? Test to see if the value of CustomField_image is empty and set it equal to the string news.

Or is this what you want:

Code: Select all
<perlCode>if ($CustomField_image eq "") {
 $CustomField_image = $CustomField_news;
}
</PerlCode>


where you test to see if CustomField_image is empty and set it to equal the value in another field?
Dale Ray
User avatar
Dale Ray
 
Posts: 1001
Joined: Sun Jan 19, 2003 6:02 pm
Location: NW Indiana

Postby Prine » Wed Oct 04, 2006 1:28 am

Thankyou guys, DaleRay, that is indeed what i was after. I want to make news the defualt value If the custom_field is empty.

1000 thankyous my friend :)
Prine
 
Posts: 7
Joined: Wed Apr 12, 2006 12:16 pm

Postby SrNupsen » Wed Oct 04, 2006 7:25 am

Hm... Couldn't this be solved by setting the default value of the field to "news" when creating it? Or from Administration -> News Fields?
-----------------------------------------------------------------------------------------------------
Coranto is free software. I am available for custom work or troubleshooting.

http://www.sundaune.no - transkripsjon, webdesign, nettsider, tekstbyrå
http://www.vagbladet.no - satire, politikk, kultur, sport, nettavis
-----------------------------------------------------------------------------------------------------
SrNupsen
 
Posts: 2229
Joined: Tue Jan 09, 2007 6:46 pm
Location: Nesodden, outside Oslo, Norway

Postby Prine » Wed Oct 04, 2006 2:34 pm

Yes, thats easily possible through admin->newsstyles, but i want the default value to be passed even if the user deletes the default value from the custom field when submiting the news (most likely by accident)

i've set up a news section for the page below, i want default image (none.jpg) to appear next to the text when the news is submitted

http://www.boxbagz.com/index.php
Prine
 
Posts: 7
Joined: Wed Apr 12, 2006 12:16 pm

Postby SrNupsen » Wed Oct 04, 2006 6:10 pm

OK I see. Well it seems to be working for you now, doesn't it?
-----------------------------------------------------------------------------------------------------
Coranto is free software. I am available for custom work or troubleshooting.

http://www.sundaune.no - transkripsjon, webdesign, nettsider, tekstbyrå
http://www.vagbladet.no - satire, politikk, kultur, sport, nettavis
-----------------------------------------------------------------------------------------------------
SrNupsen
 
Posts: 2229
Joined: Tue Jan 09, 2007 6:46 pm
Location: Nesodden, outside Oslo, Norway

Postby Parahead » Wed Oct 04, 2006 8:11 pm

SrNupsen wrote:Your two conditionals seem rather pointless to me, Parahead, since in no case the field value can at the same time be equal to both " " and "news".
Doh! :oops: You are correct, I was too tired when answering, I just took for granted it was two diferent fields, didn't really *looked* at them...
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby SrNupsen » Wed Oct 04, 2006 8:48 pm

WHOHO!!! I outsmarted you! I buried you in your own code! I win! I am invincible!!!!!

:SrNupsen:


Ops. Sorry about that. Won't happen again.
-----------------------------------------------------------------------------------------------------
Coranto is free software. I am available for custom work or troubleshooting.

http://www.sundaune.no - transkripsjon, webdesign, nettsider, tekstbyrå
http://www.vagbladet.no - satire, politikk, kultur, sport, nettavis
-----------------------------------------------------------------------------------------------------
SrNupsen
 
Posts: 2229
Joined: Tue Jan 09, 2007 6:46 pm
Location: Nesodden, outside Oslo, Norway


Return to Customization

Who is online

Users browsing this forum: No registered users and 1 guest

cron