Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-01-11 05:08:41

craigdrown
Member
Registered: 2006-01-02
Posts: 19

image categories not working after upgrade to 4.5

Hi,
we have a site that just displays photos which are arranged into image categories.
We display a category with http://mysite.net/?c=architecture where “architecture” is an image category but there is no article category called “architecture”
Working fine with earlier TXP (maybe 4.2?) but now get a 404 error
Have tried to work out how to fix it, but no joy yet.
Thanks for any pointers.
Cheers,
Craig

Offline

#2 2014-01-11 06:36:35

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: image categories not working after upgrade to 4.5

Can you post the code you are using?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2014-01-11 18:30:33

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: image categories not working after upgrade to 4.5

You probably need to add type="image" to the <txp:category /> or <txp:category_list /> tag.

Offline

#4 2014-01-12 07:53:30

milosevic
Member
From: Madrid, Spain
Registered: 2005-09-19
Posts: 390

Re: image categories not working after upgrade to 4.5

I found yesterday the same problem in my site: a section without articles, only managing image galleries based on image categories using smd_gallery.

The if_category conditional dosen’t work with or without type=image param on categories URLs.

A workarround in my case is to create article categories with the same name than image categories, then if_category tag works on that page template. I know t is not a smart solution but it works.

Last edited by milosevic (2014-01-12 07:56:47)


<txp:rocks/>

Offline

#5 2014-01-12 11:02:22

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: image categories not working after upgrade to 4.5

milosevic wrote #278072:

The if_category conditional dosen’t work with or without type=image param on categories URLs.

Try to set type="", or add context=image to the url.

Offline

#6 2014-01-12 18:11:36

craigdrown
Member
Registered: 2006-01-02
Posts: 19

Re: image categories not working after upgrade to 4.5

colak wrote #278031:

Can you post the code you are using?

Thanks! :

<div id="content">
<txp:if_category type="image">
<txp:category wraptag="H2" type="image" title="1" this_section="1" />
<!-- find out if there are children -->
<txp:variable name="HasChildren">
        <txp:category_list break="," parent='<txp:category/>' type="image" children="1" form="cat_list" exclude='<txp:category/>'/>
</txp:variable>
<txp:smd_if field="txpvar:HasChildren"
     operator="contains"
     value="*">
      <!-- there are children, so show the list of categories -->
	<div class="hfeed">
	  <txp:category_list type="image" wraptag="ul" exclude="site-design" form="gallery_front_page" break="" children="1" parent='<txp:category/>' exclude='<txp:category/>'/>
	</div>
             <txp:article id="999"/>
<txp:else/>
        <div class="hfeed"><!-- there are no children, so show the images -->
		<txp:article id="4"/>
	</div>
</txp:smd_if>
<txp:else /> <!-- no category we're on the home page -->
	<txp:if_search>
	  <h2><txp:text item="search_results" />: <txp:page_url type="q" /></h2>
	</txp:if_search>
	<div class="hfeed">
	  <txp:category_list type="image" wraptag="ul" exclude="site-design" form="gallery_front_page" break="" children="0"/>
	</div>
</txp:if_category>	
</div>

Offline

#7 2014-01-12 18:17:12

craigdrown
Member
Registered: 2006-01-02
Posts: 19

Re: image categories not working after upgrade to 4.5

etc wrote #278074:

Try to set type="", or add context=image to the url.

Adding “&context=image” to the URL did it- thanks!
(And thanks to the other posters: good ideas, and appreciate the quick response)

Offline

#8 2014-01-13 15:39:00

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,304

Re: image categories not working after upgrade to 4.5

craigdrown wrote #278088:
[more code]
<txp:variable name="HasChildren">
        <txp:category_list break="," parent='<txp:category/>' type="image" children="1" form="cat_list" exclude='<txp:category/>'/>
</txp:variable>
<txp:smd_if field="txpvar:HasChildren"
     operator="contains"
     value="*">
[more code]

Hi Craig, just an annotation re your use of the variable tag: Should the star character inside the smd_if tag be a placeholder for “any character” (couldn’t confirm that quickly browsing Stef’s doc page, so it probably just searches for stars in the category names), then the evaluation would never become false as there’s always white space (here blanks & return) inside the variable.

Generally, I’d recommend removing any white space characters/indentation from variable definitions, even if it’s easier read with these.

Edit: typos, lots

Last edited by uli (2014-01-13 15:48:40)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#9 2014-01-13 16:20:18

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: image categories not working after upgrade to 4.5

uli wrote #278108:

Generally, I’d recommend removing any white space characters/indentation from variable definitions, even if it’s easier read with these.

This done, there will be no point in using smd_if here, and one can reuse the variable:

<!-- find out if there are children -->
<txp:variable name="Children"><txp:category_list
        type="image" wraptag="ul" form="gallery_front_page" break=""
        children="1" parent='<txp:category />' exclude='<txp:category />' /></txp:variable>
<txp:if_variable name="Children" value="">
        <div class="hfeed"><!-- there are no children, so show the images -->
		<txp:article id="4" />
	</div>
<txp:else/>
      <!-- there are children, so show the list of categories -->
	<div class="hfeed">
		<txp:variable name="Children" />
	</div>
</txp:if_variable>

Offline

#10 2014-01-14 08:13:06

craigdrown
Member
Registered: 2006-01-02
Posts: 19

Re: image categories not working after upgrade to 4.5

Uli,
my code use the form=“cat_list” – this form contains a single “*” character. It works.
Can’t remember why I didn’t use your suggested idea- you’re right- it’s simpler (but haven’t verified it works)
Thanks,
Craig

Offline

Board footer

Powered by FluxBB