I've got a CCK content type using a field called 'field_news_type'
I'm looking to conditionally output some code based on the value of the CCK field. The Field has a possible 3 values: Editorial Full News Article Teaser Article
I need to do something like:
if $field_news_type = Retail Week Teaser { //dothis }
Any pointers would be appreciated.
Thanks Mark
Hi Mark,
i'd suggest that you install Content Template (contemplate) module, and Developer Module. These will help you to discover the way to reference the fields you need. For example, you will probably need to examine
$node->field_news_type[0]['value']
or something to that effect.
Also, php.net is a good source of information for basic PHP syntax.
Using these resources, you'll find your code probably looks something like this:
switch ($node->field_news_type[0]['value'] == 'Retail Week Teaser') { case 'Teaser Article': // do something break; case 'Editorial': // do something else break; case 'Full News Article': // handle this case break; }
Hope this sets you off in the right direction.
Good luck, Djun
On 25-Jul-2007, at 10:55 AM, Mark Hope wrote:
I've got a CCK content type using a field called 'field_news_type'
I'm looking to conditionally output some code based on the value of the CCK field. The Field has a possible 3 values: Editorial Full News Article Teaser Article
I need to do something like:
if $field_news_type = Retail Week Teaser { //dothis }
Any pointers would be appreciated.
Thanks Mark
On 25 Jul 2007, at 19:27, puregin wrote:
Hi Mark,
i'd suggest that you install Content Template (contemplate)module, and Developer Module.
Never had much success with contemplate but will look again at devel.
These will help you to discover the way to reference the fields you need. For example, you will probably need to examine
$node->field_news_type[0]['value']or something to that effect.
Also, php.net is a good source of information for basic PHP syntax.
Using these resources, you'll find your code probably looks something like this:
switch ($node->field_news_type[0]['value'] == 'Retail Week Teaser') { case 'Teaser Article': // do something break; case 'Editorial': // do something else break; case 'Full News Article': // handle this case break; }
Hope this sets you off in the right direction.
Good luck, Djun
Thanks for the help!
On 25-Jul-2007, at 10:55 AM, Mark Hope wrote:
I've got a CCK content type using a field called 'field_news_type'
I'm looking to conditionally output some code based on the value of the CCK field. The Field has a possible 3 values: Editorial Full News Article Teaser Article
I need to do something like:
if $field_news_type = Retail Week Teaser { //dothis }
Any pointers would be appreciated.
Thanks Mark
themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes
Minor Point
switch ($node->field_news_type[0]['value'] == 'Retail Week Teaser') {
should be
switch ($node->field_news_type[0]['value']) {
Steve Ringwood Nevets Software
Mark,
Perhaps you are not familiar with the Drupal Dojo group, which has an ongoing series of lessons covering these and other interesting stuff, just the thing for people getting more involved in intermediate and advanced Drupal fine tuning and more.
The group: http://groups.drupal.org/drupal-dojo
Special group site with lesson roundups: http://drupaldojo.com
Class notes on theming lesson that was broadcast (you can download the notes and the code from the class, and maybe even the old video podcast):
1. notes: http://groups.drupal.org/node/2764 2. more references on the same lesson: http://drupaldojo.com/lesson/theming-and-the-themer-pack
saludos,
Victor Kane http://awebfactory.com.ar
On 7/25/07, Mark Hope mark@markhope.net wrote:
On 25 Jul 2007, at 19:27, puregin wrote:
Hi Mark,
i'd suggest that you install Content Template (contemplate)module, and Developer Module.
Never had much success with contemplate but will look again at devel.
These will help you to discover the way to reference the fields you need. For example, you will probably need to examine
$node->field_news_type[0]['value']or something to that effect.
Also, php.net is a good source of information for basic PHP syntax.
Using these resources, you'll find your code probably looks something like this:
switch ($node->field_news_type[0]['value'] == 'Retail Week Teaser') { case 'Teaser Article': // do something break; case 'Editorial': // do something else break; case 'Full News Article': // handle this case break; }
Hope this sets you off in the right direction.
Good luck, DjunThanks for the help!
On 25-Jul-2007, at 10:55 AM, Mark Hope wrote:
I've got a CCK content type using a field called 'field_news_type'
I'm looking to conditionally output some code based on the value of the CCK field. The Field has a possible 3 values: Editorial Full News Article Teaser Article
I need to do something like:
if $field_news_type = Retail Week Teaser { //dothis }
Any pointers would be appreciated.
Thanks Mark
themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes
themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes
On 25 Jul 2007, at 22:17, Victor Kane wrote:
Mark,
Perhaps you are not familiar with the Drupal Dojo group, which has an ongoing series of lessons covering these and other interesting stuff, just the thing for people getting more involved in intermediate and advanced Drupal fine tuning and more.
Yes I am aware of it, and thanks for the reminder.
Just needed a quick pointer in the right direction on this issue though - php/theming is not my 'main role' and I'm trying to fix something before going on holiday tomorrow. Not packed, not getting any sleep and still got a long to do list!
Have heard good things about the DoJo group so will give it go soon.
Thanks Mark
The group: http://groups.drupal.org/drupal-dojo
Special group site with lesson roundups: http://drupaldojo.com
Class notes on theming lesson that was broadcast (you can download the notes and the code from the class, and maybe even the old video podcast):
- notes: http://groups.drupal.org/node/2764
- more references on the same lesson: http://drupaldojo.com/
lesson/theming-and-the-themer-pack
saludos,
Victor Kane http://awebfactory.com.ar
OK,Mark, good luck, then -- the specific lesson I mentioned may include some code that can help you do exactly what you are looking for, however.
saludos,
Victor
On 7/25/07, Mark Hope mark@markhope.net wrote:
On 25 Jul 2007, at 22:17, Victor Kane wrote:
Mark,
Perhaps you are not familiar with the Drupal Dojo group, which has an ongoing series of lessons covering these and other interesting stuff, just the thing for people getting more involved in intermediate and advanced Drupal fine tuning and more.
Yes I am aware of it, and thanks for the reminder.
Just needed a quick pointer in the right direction on this issue though - php/theming is not my 'main role' and I'm trying to fix something before going on holiday tomorrow. Not packed, not getting any sleep and still got a long to do list!
Have heard good things about the DoJo group so will give it go soon.
Thanks Mark
The group: http://groups.drupal.org/drupal-dojo
Special group site with lesson roundups: http://drupaldojo.com
Class notes on theming lesson that was broadcast (you can download the notes and the code from the class, and maybe even the old video podcast):
- notes: http://groups.drupal.org/node/2764
- more references on the same lesson:
http://drupaldojo.com/lesson/theming-and-the-themer-pack http://drupaldojo.com/lesson/theming-and-the-themer-pack
saludos,
Victor Kane http://awebfactory.com.ar
themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes