PDA

View Full Version : mod cattree


dreamingdigital
08-12-06, 12:03 AM
I've been working on this all afternoon and I'm stuck. The module dev. - Sebenza - Scott - won't help because it's something extra. I'm tired of wasting time on this script and need some help/guidance!!!

I want to display the top 2 categories and their subcategories all the time in my cattree. Then I want the cattree to behave normally. I just want the top 2 levels open all the time. I have a parts section and a complete items section and I want their subsections open so the top two are more like separators than links, but because we can only have 1 category tree I need to do it this way.

I have Sebenza's cattree template module installed and I'm trying to tweak it. This is what I've done to it. Parent ID 9 and Parent ID 28 are the two main categories that everything is based on. There has to be a simple solution to this!! I put in the parent id numbers into the output for debugging.
<mvt:foreach iterator="tree" array="cattree">
<mvt:if expr="g.Category_Code EQ l.settings:tree:code">
<!-- if the category is the current page -->
<mvt:if expr="l.settings:tree:image">
&mvt:tree:pad;<a href="&mvt:global:sessionurl;Screen=CTGY&Store_Code=&mvta:store:code;&Category_Code=&mvta:tree:code;" class="&mvt:tree:class;"><img src="&mvt:tree:image;" border="0" alt="&mvt:tree:name;"></a><br>
<mvt:else>
&mvt:tree:pad;<b>&gt;</b>&nbsp;<a href="&mvt:global:sessionurl;Screen=CTGY&Store_Code=&mvta:store:code;&Category_Code=&mvta:tree:code;" class="&mvt:tree:class;" style="font-weight:bold;">&mvt:tree:name;</a><br>
</mvt:if>
<mvt:else>
<mvt:if expr="l.settings:tree:parent_id EQ 0">
<!-- for if is the top level category -->
<mvt:if expr="l.settings:tree:image">
&mvt:tree:pad;<a href="&mvt:global:sessionurl;Screen=CTGY&Store_Code=&mvta:store:code;&Category_Code=&mvta:tree:code;" class="&mvt:tree:class;"><img src="&mvt:tree:image;" border="0" alt="&mvt:tree:name;"></a><br>
<mvt:else>
&mvt:tree:pad;0•&nbsp;<a href="&mvt:global:sessionurl;Screen=CTGY&Store_Code=&mvta:store:code;&Category_Code=&mvta:tree:code;" class="&mvt:tree:class;">&mvt:tree:name;</a><br>
</mvt:if>

<mvt:elseif expr="l.settings:tree:parent_id EQ 9">
<!-- for if is the top level category's child -->
<mvt:if expr="l.settings:tree:image">
&mvt:tree:pad;<a href="&mvt:global:sessionurl;Screen=CTGY&Store_Code=&mvta:store:code;&Category_Code=&mvta:tree:code;" class="&mvt:tree:class;"><img src="&mvt:tree:image;" border="0" alt="&mvt:tree:name;"></a><br>
<mvt:else>
&mvt:tree:pad;9•&nbsp;<a href="&mvt:global:sessionurl;Screen=CTGY&Store_Code=&mvta:store:code;&Category_Code=&mvta:tree:code;" class="&mvt:tree:class;">&mvt:tree:name;</a><br>
</mvt:if>

<mvt:elseif expr="l.settings:tree:parent_id EQ 28">
<!-- for if is the top level category's child -->
<mvt:if expr="l.settings:tree:image">
&mvt:tree:pad;<a href="&mvt:global:sessionurl;Screen=CTGY&Store_Code=&mvta:store:code;&Category_Code=&mvta:tree:code;" class="&mvt:tree:class;"><img src="&mvt:tree:image;" border="0" alt="&mvt:tree:name;"></a><br>
<mvt:else>
&mvt:tree:pad;28•&nbsp;<a href="&mvt:global:sessionurl;Screen=CTGY&Store_Code=&mvta:store:code;&Category_Code=&mvta:tree:code;" class="&mvt:tree:class;">&mvt:tree:name;</a><br>
</mvt:if>

<mvt:else>
<!-- for if is a subcats of top level category's child -->
<mvt:if expr="l.settings:tree:image">
&mvt:tree:pad;<a href="&mvt:global:sessionurl;Screen=CTGY&Store_Code=&mvta:store:code;&Category_Code=&mvta:tree:code;" class="&mvt:tree:class;"><img src="&mvt:tree:image;" border="0" alt="&mvt:tree:name;"></a><br>
<mvt:else>
&mvt:tree:pad;•&nbsp;<a href="&mvt:global:sessionurl;Screen=CTGY&Store_Code=&mvta:store:code;&Category_Code=&mvta:tree:code;" class="&mvt:tree:class;">&mvt:tree:name;</a><br>
</mvt:if>


</mvt:if>
</mvt:if>
</mvt:foreach>

Here is a link to see the code in action. It does what I tell it to do. But not what I want the overall effect to do. I most likely don't understand how the cattree gets looped and written.

http://miva.rctoys.com/Merchant2/merchant.mvc?Screen=SFNT

Click on the cattree links. The store has nothing in it but categories so far.

PLEASE help.

PicturesqueWeb
08-16-06, 09:12 PM
I'd make the categories and subcategories all main categories. Use tree image to have your current two main categories stand out and appear as main categories even though they aren't. Of course you'd need content on these pages for when people click on them directing them to the subs, but that sounds easier than what you are trying to do.

dreamingdigital
08-16-06, 09:37 PM
That's a good idea I guess. I could even bypass having it link those 2 main category images by knowing their ID's. Good advice.

adam2003w
05-08-07, 05:13 PM
It looks like you got this working on your site. Care to share the code? I'm using the sebenza cattree module and trying to do a similar thing.

dreamingdigital
05-09-07, 05:48 AM
Here's the jist of how we pulled it off. We made our 2 primary categories not categories at all - it just looks like they are:


start foreach loop
check to see if the category code is one of the ones we want to display a parent category name above
if so display the correct parent category code based on the category code
if not keep going through loop
end foreach loopI think Scot added some new features to this module though now. Maybe even exactly what you want. I'd get an update and read the latest docs.