We are trying to add the node type into the Ad Unit pattern but none of the node tokens seem to be being rewritten.

We want to use "[node:content-type:machine-name]", to produce something like:

googletag.defineSlot("/6831/LN_newlawjournal/countdown", [728, 90], "dfp-ad-nlj_lb")

But we are getting:

googletag.defineSlot("/6831/LN_newlawjournal/[node:content-type:machine-name]", [728, 90], "dfp-ad-nlj_lb")

As you can see the node tokens are converted fine in the targeting and global settings.

dfp_1.png

dfp_2.png

CommentFileSizeAuthor
#10 1895522.patch1.58 KBbleen
#5 1895522.patch4.55 KBbleen
#1 dfp-tokens.patch2.03 KBbleen
dfp_2.png59.4 KBsoulston
dfp_1.png144.22 KBsoulston

Comments

bleen’s picture

Status: Active » Needs review
StatusFileSize
new2.03 KB

This one was pretty straight forward ... I was not passing "node" to the token replace used by ad_unit

bleen’s picture

Status: Needs review » Fixed

I went ahead and committed this

soulston’s picture

Thanks - confirmed this is working

soulston’s picture

Status: Fixed » Active

Sorry to be a total pita but it might be good to expose these in the UI. I am guessing this needs:

dfp_ctools_export_ui.inc

  $form['tag_settings']['tokens'] = array(
    '#theme' => 'token_tree',
    '#token_types' => array('dfp_tag'), // The token types that have specific context. Can be multiple token types like 'term' and/or 'user'

to

  $form['tag_settings']['tokens'] = array(
    '#theme' => 'token_tree',
    '#token_types' => array('dfp_tag', 'node', 'term', 'user'), // The token types that have specific context. Can be multiple token types like 'term' and/or 'user'

Would these types be better placed in a global array or something so that they are more easily edited etc?

I'll create a patch once you have updated the repo again.

bleen’s picture

Status: Active » Needs review
StatusFileSize
new4.55 KB

how bout this

soulston’s picture

Status: Needs review » Reviewed & tested by the community

This works for me - thanks

bleen’s picture

Status: Reviewed & tested by the community » Fixed

awesome ... committed

davidfells81@gmail.com’s picture

Should also pass array('clean' => TRUE) to the token_replace function - without that I still end up with empty tags in some circumstances (for example, a [term:name] target on a unit that also appears on a node/% page)

bleen’s picture

Status: Fixed » Needs review

An excellent suggestion ... though it should really be array('sanitize' => TRUE)

... in the future please open a new bug/feature request

bleen’s picture

StatusFileSize
new1.58 KB

oops .. forgot patch

bleen’s picture

Status: Needs review » Fixed

committed the patch from #11

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.