Page 1 of 1

Unofficial Fix for ConLib:SimilarProducts/MoreCategoryItems

Posted: Fri Mar 14, 2008 4:50 am
by dave_reach
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.

Posted: Fri Mar 14, 2008 11:14 pm
by AbleMods
Dave, both those controls have a quantity and orientation parameter you can specify in the scriptlet - that isn't working?

Posted: Mon Mar 17, 2008 2:11 am
by dave_reach
Nups, was just drawing in one, long, horizontal line when set to horizontal or vertical, otherwise I wouldn't have fixed it :wink:

Re: Unofficial Fix for ConLib:SimilarProducts/MoreCategoryIt

Posted: Mon Mar 17, 2008 7:56 am
by bobr2k
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?

Re: Unofficial Fix for ConLib:SimilarProducts/MoreCategoryIt

Posted: Mon Mar 17, 2008 8:38 am
by dave_reach
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!