PDA

View Full Version : 'Conditional Inlcudes' in templates


Josiah Bounderby
11-26-2005, 03:08 PM
I have modified my templates to allow me to use conditional includes, ie. text that only appears in certain specified categories.

Code follows:
Content visible to registered users only.

.... which works fine :)

However, it would be really cool if I could make the code conditional on the parent category.

I used "category.ID" for the category number.
Is there an equivalent code for the parent category?

(In case you haven't guessed, I am a complete twonk when it comes to PHP - just hacking my way through using perfect logic on bad data ;))

David
11-26-2005, 03:50 PM
Yes, this is a good start. The problem with being able to follow the category tree from child to parent to parent is it can consume a good deal of resources. What I'm planning on implementing in 3.0 (maybe not in the initial release) is a maintenance feature in admin that allows you to run a tool that builds the relationships for fast acess, so for example, after running the tool, we would know that
catID 246 is the child of catID 27 is the child of catID 4
and have quick access to this information.

Josiah Bounderby
11-26-2005, 08:12 PM
I must have misunderstood something here.

In the MySQL data, each category has its parent ID listed in its record.

Is there not some way we can easily access that info?

Sorry if its a daft question.

David
11-27-2005, 12:54 AM
Content visible to registered users only.

Well, it gets tricky when there are multiple levels. It's easy to quickly grab the parent ID, but when it comes to grandparents and great grandparents it gets rather tricky.

Not to change the subject, but let's say for example that you are using mod rewrite, and you want to simply display the last 10 categories added on a separate page. This would be difficult. Or maybe you wanted to create a sitemap showing ALL categories. It is very feasible under the current architecture, but I plan to change that.

If we are only dealing with one parentID, I think there will be a quick answer to your question. I don't have the answer, but likely someone here could answer it.

Josiah Bounderby
11-27-2005, 01:21 AM
In my case, I only need the 'parent' - it's not a major issue, it would just mean a whole load less '{if $category.ID == .......' coding.

anyone?