If num=? do this - help required
3 posts by 2 authors in: Forums > CMS Builder
Last Post: April 23, 2011 (RSS)
By (Deleted User) - April 23, 2011
Hello,
Similar to the php at the start of the page where I have
How would I put this into practice on the page itself. So lets say.
If num = 80 do this
<?php echo $listing_pagesRecord['title'] ?>
If num = 81 do this
<?php echo $listing_pagesRecord['title_long'] ?>
But all nicely in one long <?php if query??
Thanks for your help.
Jono
Similar to the php at the start of the page where I have
'where' => "num='80",
How would I put this into practice on the page itself. So lets say.
If num = 80 do this
<?php echo $listing_pagesRecord['title'] ?>
If num = 81 do this
<?php echo $listing_pagesRecord['title_long'] ?>
But all nicely in one long <?php if query??
Thanks for your help.
Jono
Re: [jonoc73] If num=? do this - help required
By gkornbluth - April 23, 2011
Hi Jono,
Since the 'num' field is just another field in a table, you can probably use an approach similar to this one excerpted from a recipe in my CMSB Cookbook thecmsbcookbook.com Replacing "group_code" with "num"
SETTING UP IF/THEN CONDITIONS
If the group_code of the particular record is “book” then I wanted to display field “A”, if it’s “CD” I’d like to display
field “B”, if it’s “magazine” I’d like to display field “C”, and if it’s none of those I’d like to display field
“D”.
The task is pretty straightforward once you know the correct format to use.
If you’re using it on multi record a list page:
And if it’s on a single page or a detail page:
You can use this to display anything that you want to, in another situation I’m using it to display different thumbnail groups for different group codes. Just replace the <?PHP echo $record['fieldn'] ?> codes with the code that will display what you want to.
There’s much more on understanding and using if statements in other recipes in the Cookbook.
______________________________________________
Hope that gives you some ideas.
Best,
Jerry Kornbluth
Since the 'num' field is just another field in a table, you can probably use an approach similar to this one excerpted from a recipe in my CMSB Cookbook thecmsbcookbook.com Replacing "group_code" with "num"
SETTING UP IF/THEN CONDITIONS
If the group_code of the particular record is “book” then I wanted to display field “A”, if it’s “CD” I’d like to display
field “B”, if it’s “magazine” I’d like to display field “C”, and if it’s none of those I’d like to display field
“D”.
The task is pretty straightforward once you know the correct format to use.
If you’re using it on multi record a list page:
<?PHP foreach ($pub_category_listRecords as $record): ?>
<?PHP if ($record['group_code'] == "book"): ?>
<?PHP echo $record['fieldA'] ?>
<?PHP elseif ($record['group_code'] == "CD"): ?>
<?PHP echo $record['fieldB'] ?>
<?PHP elseif ($record['group_code'] == "Magazine"): ?>
<?PHP echo $record['fieldC'] ?>
<?PHP else: ?>
<?PHP echo $record['fieldD'] ?>
Sorry, couldn't find a match for '<?PHP echo $record['group_code'] ?>'
<?PHP endif ?>
<?PHP endforeach; ?>
And if it’s on a single page or a detail page:
<?PHP if ($pub_category_listRecord['group_code'] == "book"): ?>
<?PHP echo $pub_category_listRecord['fieldA'] ?>
<?PHP elseif ($pub_category_listRecord['group_code'] == "CD"): ?>
<?PHP echo $pub_category_listRecord['fieldB'] ?>
<?PHP elseif ($pub_category_listRecord['group_code'] == "Magazine"): ?>
<?PHP echo $pub_category_listRecord['fieldC'] ?>
<?PHP else: ?>
<?PHP echo $pub_category_listRecord['fieldD'] ?>
Sorry, couldn't find a match for '<?PHP echo $pub_category_listRecord['group_code'] ?>'
<?PHP endif ?>
You can use this to display anything that you want to, in another situation I’m using it to display different thumbnail groups for different group codes. Just replace the <?PHP echo $record['fieldn'] ?> codes with the code that will display what you want to.
There’s much more on understanding and using if statements in other recipes in the Cookbook.
______________________________________________
Hope that gives you some ideas.
Best,
Jerry Kornbluth
The first CMS Builder reference book is now available on-line!
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] If num=? do this - help required
By (Deleted User) - April 23, 2011
Works just as requested - thanks!