exploding [termpath]
matthew_ellis24 - June 30, 2008 - 20:15
| Project: | Token |
| Version: | 6.x-1.12 |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Hello, I want to use some of the terms from termpath. As you know it outputs it as a "/" seperated string. I had hoped it would be as easy it using the PHP explode command to cherry pick the terms I want. However I can't get it to work.
this doesn't work
<?php
$name=explode("/",[termpath]);
print $name[2];
?>and nor does this
<?php
$name=explode("/",$node->[termpath]);
print $name[2];
?>Both give the error
Parse error: parse error, unexpected '/', expecting T_STRING or T_VARIABLE or '{' or '$' in /home/content/c/a/r/carabusonline/html/sites/all/modules/auto_nodetitle/auto_nodetitle.module(177) : eval()'d code on line 2I know I'm being daft, I just can't figure out how else to do this.
Many thanks for the patience of anyone who answers me :D

#1
I believe the problem is that your second argument to it is not the actual token. You have to get tokens before you can use them.
You'll need something like
<?php$node = node_load(arg(1));
$tokens = token_get_values('node', $node);
$name=explode("/",$tokens['termpath']);
print $name[2];
?>
This is something that the tokenize module can do on cck fields. So, perhaps you'll want to look at that module.
#2
thanks, I thought it might be something like that, but I wasn't sure how to get the actual token variables. Unfortunately I've broken hierarchical select so I can't sort this out till I get that working (as that's where the terms will be coming from).
But thanks for your help, I'll be sure to give tokenize a bash
Thanks
Matt
#3
Automatically closed -- issue fixed for two weeks with no activity.
#4
don't work on Token for Drupal 6.
please help.
thx.
#5
don't work on Token for Drupal 6.
please help.
thx.