Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-01-01 23:53:28

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Filter image categories

hi,

What’s the best way (from within an article form) to get :

A) All the images categories ( just the categories , not the images )

B) Limit the output of the img categories by number ( allowing to determine offset aswell )

C) Filter them by

  • alphabet
  • asc, desc by date
  • number of images assigned to each of them as desc and asc
  • popularity ( number of times queried already from frontend side )

( I could imagine, some SQL queries might be involved , I’d be grateful for any hints )

regards, marios

Last edited by marios (2007-01-02 00:03:07)


⌃ ⇧ < ⌃ ⇧ >

Offline

#2 2007-01-02 01:10:01

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: Filter image categories

For A) and B), if I do:
select name from txp_category where type = ‘image’ limit 1 offset 2
how do I embed it using the txp php tag ?
I have been reading it twice, but can’t remember how it’s done.

Anyone ?

regards, marios


⌃ ⇧ < ⌃ ⇧ >

Offline

#3 2007-01-02 13:37:42

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Filter image categories

<txp:category_list type="image" />

category_list

If it doesn’t do all that you want, then find a plugin.

Offline

#4 2007-01-02 16:46:54

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: Filter image categories

Yes, that’s what I thought also, Mary. So I tried a link=“0” attribute on that one, which of course will not work.
Doing a querry directly returns me the category name.
But doing for instance:

<txp:php>$imgcat = safe_query(“SELECT name FROM txp_category WHERE type = ‘image’ limit 1”); echo “$imgcat”;
echo “test”; </txp:php>

returns :

Resource id #33test

instead of the category name.

regards, marios


⌃ ⇧ < ⌃ ⇧ >

Offline

#5 2007-01-02 17:31:01

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Filter image categories

<txp:php>
	$imgcat = safe_field('name', 'txp_category', "type = 'image' LIMIT 1");
	echo $imgcat;
</txp:php>

Last edited by Mary (2007-01-02 20:53:45)

Offline

#6 2007-01-02 20:51:26

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: Filter image categories

Supposedly , those db helperfunctions take variables as arguments and not sql statements.

However. It’ll just throw errors in my install.

Any other Ideas ?

regards, marios


⌃ ⇧ < ⌃ ⇧ >

Offline

#7 2007-01-02 20:54:30

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Filter image categories

Bah, sorry, wasn’t thinking. Check updated code.

Offline

#8 2007-01-02 21:20:53

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: Filter image categories

I’m getting more love with this one, thanks a lot mary.
(However, the whole thing will keep me busy for another couple of days , I suspect)

regards, marios


⌃ ⇧ < ⌃ ⇧ >

Offline

Board footer

Powered by FluxBB