By manila555 on
Hi,
I'm a complete newbie to Drupal and PHP and would like some assistance in getting some basic php working.
In a tpl.php file I'm trying to create a link depending on a category and I can't seem to get the a href to work.
Here's my code:
switch ($node->field_cc_resource_category[0]['view'])
{
case "Interview Preparation":
$button = "<a href="../book-appointment"> Book an Appointment for Interview tips </a>";
break;
case "Resume Consultation":
$button = "<a href="../book-appointment"> Book an Appointment to Enhance your Resume </a>";
break;
}
?>
Any help is greatly appreciated.
Thanks
Comments
try this
You should also look into t() and l() functions anytime you deal with strings.
Awesome Thanks! I didn't
Awesome Thanks!
I didn't realize that I needed a "\" for the "a href" tag.
Interesting.
Instead of
Instead of
you can try
In general terms the function l() takes several arguments. The first is the link text, the second the Drupal path. The t() function allows the text to be translated.
Great explanation! Thank You!
Great explanation! Thank You!
hi manila555 could u please
hi manila555
could u please describe what result your getting out of the above code.
and
If "Interview Preparation" and "Resume Consultation" are the only 2 possible values that $node->field_cc_resource_category[0]['view'] can hold then why not use an 'if ... else' statement .