4

I've been using Low Seg2Cat for ages now on my blog pages to display category information and do category archive pages. I just realised today that the {segment_x_category_image} tag is not working properly. If I view the page source I'm getting this:

{filedir_1}badge-ideas.gif

I know the image is fine because on a single entry page I call it with this:

{categories}{category_image}{/categories}

and it displays correctly.

Is there something wrong with this Seg2Cat tag?

I've updated to latest version of Seg2Cat and it didn't fix the issue.

2 Answers 2

3

Low Seg2Cat is meant to be as lightweight as possible. That means narrowing down on DB queries. As it might not be necessary for everyone to use the image tag, that could mean a superfluous query every page load. Instead, use something like Parse File Paths (free) to parse those {filedir_x} vars:

{exp:parse_file_paths}{segment_x_category_image}{/exp:parse_file_paths}
2
  • OK that's cool. But what's the point of having the {segment_x_category_image} tag if it doesn't work without the dependency of another plugin? Commented May 2, 2013 at 7:07
  • The Category Image field was just a plain old text input field for a long time. It's only in a fairly recent update that EllisLab changed it to a proper File field. Lots of people used the Image field for something other than an image before that update, so it wasn't necessary. I do get your point tho. Will make a note of it.
    – Low
    Commented May 2, 2013 at 7:38
0

Was trying to avoid having to add another add-on, am already using Surgeree for string stuff so I was able to do this as an alternative:

{exp:surgeree:strip_tags}
    {exp:channel:categories show="{segment_2_category_id}"}{category_image}{/exp:channel:categories}
{/exp:surgeree:strip_tags}

That leaves you with just the image url, if you use it with Stash you can use the trim parameter, e.g. wrap the above with {exp:stash:set name="main_image" parse_tags="yes"} and for your image:

<img src="{exp:stash:get name="main_image" trim="yes"}" alt="{segment_2_category_name}" />

...

Probably makes more sense to use the parse file paths add on. but this will do the trick for me for now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.