Add three Taxonomy terms to node title and text processing

Events happening in the community are now at Drupal community events on www.drupal.org.
daviesap's picture

Hi

Hope this is a good place to post.

I've set up a rule which automatically puts three taxonomy terms that are set in the node using three term ref fields - into the node title.

However - I have the following two problems :

1) I need to process the text so that text is added before / after Some of the the tax terms - ie:

[parent of tax term from vocabulary 1], [tax term from vocabulary 1] in [tax term from vocabulary 2] with a [tax term from vocabulary 3]

2) Some of the vocabs are not assigned - so I need a conditional If / then so that rules only adds the term if it has content along with relevant preceding text (at the moment, the tag [term....] is printed if it's empty. )

The three vocabularies are assigned to each node using a term reference field.

As you'll see from above, one of the vocabs is hierachical (but only two levels)

I'm on drupal 7 and the latest release of rules / entity.

Any help much appreciated.

Thanks

Andrew

Comments

OK Have made some progress,

daviesap's picture

OK Have made some progress, but after hours have hit a brick wall.

Really hope someone can help.

I have assigned a replacement pattern to a variable in PHP, so :

$fitting_group = "[node:field-product-type-tax:parent:name]"; (within PHP tags)

Printing that variable if it contains data works perfectly, but if that field hasn't been set, it returns "[node:field-product-type-tax:parent:name]"

If I write :

If ($fitting_group == "[node:field-product-type-tax:parent:name]") {

$fitting_group = "";
}

It always returns true as naturally the pattern just gets replaced again. It seems as if the replacement pattern within the [ ] is rendered separately to PHP? I even tried :

If (substr($fitting_group, -1)) == "]") to see if it would trick it but again that didn't work. It returns "]" if there is data in there or not.

Can anyone help? Please!!!

Thanks,

Andrew

After a heck of a lot of

daviesap's picture

After a heck of a lot of searching and head banging, I found the new "Data value is empty" selector in the latest Dev version.

Have had to set up two rules, so that it can test which fields are empty - seems a bit clunky but has done the trick.

Thanks - shame I didn't find out about the Data value is empty option sooner.

(4.30am here in Dubai now. Heck - got to get up at 5.30am!)

So did I just post this in

daviesap's picture

So did I just post this in the wrong place?

Rules

Group organizers

Group categories

Categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: