Unofficial Fix for ConLib:SimilarProducts/MoreCategoryItems

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
dave_reach
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 32
Joined: Mon Jan 28, 2008 10:05 am

Unofficial Fix for ConLib:SimilarProducts/MoreCategoryItems

Post by dave_reach » Fri Mar 14, 2008 4:50 am

I've just been trying to use the MoreCategoryItems and SimilarProducts user controls in horizontal mode - however they weren't drawing <TR>, and all the products were being listed in one massive, site destroying line.

Fixed as follows, for anyone else doing this;

Code: Select all

Step1. Create a private variable in the <Control>.ascx.cs file

21: private int colsDrawn=0;

Code: Select all

Step 2. Create a new public function

public void drawn() {
        this.colsDrawn++;
}

Code: Select all

Step 3. Overwrite/Modify the 'GetRow()' function

183:    public string GetRow(bool open,bool horizontal) {
184:        bool isHorizontalMode=(_Orientation=="HORIZONTAL");
185:        if(!(isHorizontalMode==horizontal)) {
186:            if(open&&(colsDrawn==0))
187:                return "<tr>";
188:            if(this.colsDrawn==3) {
189:                this.colsDrawn=0;
190:                return "</tr>";
191:            }
192:        }
193:        return string.Empty;
194:    }

Code: Select all

Step 4. Add a call to drawn() to the .ascx page

29:   </td>
30:   <GetRow>
31:   <drawn>
32: </ItemTemplate>
Et Voila! Except the forum automatically removes code tags (<%) within code blocks. For Step 4 use...

30: %= GetRow(false, false) %
31: % drawn(); %

...between the markup tags.

Oh, i've also hard coded it to draw 3 columns, you could either change the line:

188: if(this.colsDrawn==3) {

to check against a different number, or to 'this.Columns' to use the argument provided by the user control parameters.

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Post by AbleMods » Fri Mar 14, 2008 11:14 pm

Dave, both those controls have a quantity and orientation parameter you can specify in the scriptlet - that isn't working?
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

dave_reach
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 32
Joined: Mon Jan 28, 2008 10:05 am

Post by dave_reach » Mon Mar 17, 2008 2:11 am

Nups, was just drawing in one, long, horizontal line when set to horizontal or vertical, otherwise I wouldn't have fixed it :wink:

User avatar
bobr2k
Commander (CMDR)
Commander (CMDR)
Posts: 183
Joined: Fri Oct 26, 2007 2:31 pm
Location: Illinois

Re: Unofficial Fix for ConLib:SimilarProducts/MoreCategoryIt

Post by bobr2k » Mon Mar 17, 2008 7:56 am

dave_reach wrote: Except the forum automatically removes code tags (<%) within code blocks. For Step 4 use...
Did you check Disable HTML in this post?
Bob R.
"Bills travel through the mail at twice the speed of checks." -- Steven Wright

dave_reach
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 32
Joined: Mon Jan 28, 2008 10:05 am

Re: Unofficial Fix for ConLib:SimilarProducts/MoreCategoryIt

Post by dave_reach » Mon Mar 17, 2008 8:38 am

bobr2k wrote:
dave_reach wrote: Except the forum automatically removes code tags (<%) within code blocks. For Step 4 use...
Did you check Disable HTML in this post?
It's highly likely :roll: Although come to think of it it's enabled by default and I didn't change any of the tick boxes, so possibly not. Hmm!

Post Reply