I've got a block view set up to get the latest 3 blog posts by term. I'm using Term ID with depth as the argument and providing the default arg using php code with return arg(1); as the arg.
Works fine in views preview with arguments entered, but on an actual page it returns nothing. Never had a problem with this before in 6.x. Is there something new I'm completely missing? I've read through docs and tried a few different ways to return the default arg, but no luck.
The view is attached. Any help would be greatly appreciated.
Comments
Comment #1
wizonesolutionsHave you printed (e.g. with dsm) arg(1) to make sure it's what you expect? I'm surprised it works while editing the view. Normally I have the opposite issue, although I haven't used Views 7 much and as such probably aren't qualified to comment. But thought I'd take a stab :)
Comment #2
jseltzer commentedYeah, I tried changing the argument code to account for pathauto aliasing (even though the aliases worked before in preview.
So I changed the term id argument code to
Using dpm on $path[1] gives me the term alias and I assumed that the Argument validator for Taxonomy Terms, which is set to "Term Name converted to Term ID", would get me the ID, but maybe not?
Comment #3
jseltzer commentedAdded a
return '';to the default argument if the statement was false and that did the trick. Not entirely sure why though.Comment #4
doompal commentedPerhaps because your code is expected to return a value in every case?