Rank: Member
Joined: 7/15/2004(UTC) Posts: 368
|
When someone first comes to a site and the Recently Viewed module is used, all that they see is the <h4> tag because no products have been viewed yet. Is there a way to "hide" that <h4> tag until products are viewed? Or maybe include that with the code that produces the product list...
I don't want to use the Recently Viewed list on the home page but on the category page would be useful. Also, if someone enters the site on the product page itself they too would get that header with no content. |
|
|
|
|
Rank: Member
Joined: 8/17/2006(UTC) Posts: 681
|
BVModules\ContentBlocks\Last Products Viewed\view.ascx.vb LoadProductGrid:
If myProducts IsNot Nothing And myProducts.Count > 0 Then Me.DataList1.DataSource = n ..... old code
Else Me.FindControl("recentlyViewed").Visible = False End If
Corneliu. |
|
|
|
|
Rank: Member
Joined: 7/15/2004(UTC) Posts: 368
|
I can't locate that specific code Code:If myProducts IsNot Nothing And myProducts.Count > 0 Then Me.DataList1.DataSource = n when I went with what I thought it was an added your code, it didn't work. What am I missing? Here's where I attempted to put it. Code: If myProducts IsNot Nothing Then Me.DataList1.DataSource = n Me.DataList1.DataBind()
Dim display As Integer = SettingsManager.GetIntegerSetting("LPVDisplayTypeRad").ToString
If display = 0 Then Me.DataList1.RepeatDirection = RepeatDirection.Horizontal Me.DataList1.RepeatColumns = SettingsManager.GetIntegerSetting("LPVGridColumnsField") ElseIf display = 1 Then Me.DataList1.RepeatDirection = RepeatDirection.Vertical Me.DataList1.RepeatColumns = SettingsManager.GetIntegerSetting("LPVDisplayTypeRad") Else Me.DataList1.RepeatDirection = RepeatDirection.Horizontal Me.DataList1.RepeatColumns = 3 End If
End If
|
|
|
|
|
Rank: Member
Joined: 8/17/2006(UTC) Posts: 681
|
Wanita, The code I gave you is new so your attempt is good. You miss te else bit before your new end if. This should be the result:
If myProducts IsNot Nothing And myProducts.Count > 0 Then
Me.DataList1.DataSource = n Me.DataList1.DataBind()
Dim display As Integer = SettingsManager.GetIntegerSetting("LPVDisplayTypeRad").ToString
If display = 0 Then Me.DataList1.RepeatDirection = RepeatDirection.Horizontal Me.DataList1.RepeatColumns = SettingsManager.GetIntegerSetting("LPVGridColumnsField") ElseIf display = 1 Then Me.DataList1.RepeatDirection = RepeatDirection.Vertical Me.DataList1.RepeatColumns = SettingsManager.GetIntegerSetting("LPVDisplayTypeRad") Else Me.DataList1.RepeatDirection = RepeatDirection.Horizontal Me.DataList1.RepeatColumns = 3 End If
Else Me.FindControl("recentlyViewed").Visible = False End If
Corneliu. |
|
|
|
|
Rank: Member
Joined: 3/15/2007(UTC) Posts: 126
|
To get this to work properly I would recommend adding a <div> outside of the literal like this: *See top line (<div id="RecentlyViewedTest" runat="server">)
<div id="RecentlyViewedTest" runat="server"> <asp:Literal ID="PreHtml" runat="server"></asp:Literal> <div class="productgrid"> <div class="decoratedblock"> <div class="blockcontent"> <h4><asp:Label ID="LPVTitle" runat="server"></asp:Label></h4> <asp:DataList ID="DataList1" runat="server" DataKeyField="bvin" RepeatLayout="Table"> <ItemTemplate> <table> <tr> <td> <a href="<%#Eval("ProductURL") %>"><img id="imagesmall" runat="server" class="lastproductsviewed"/></a> </td> </tr> <tr> <td> <a href="<%#Eval("ProductURL") %>"><%#Eval("ProductName")%></a> </td> </tr> </table> </ItemTemplate> </asp:DataList> </div> </div> </div> <asp:Literal ID="PostHtml" runat="server"></asp:Literal> </div>
============================================================== Then alter code to reference the div ID like this: * see below (Me.FindControl("RecentlyViewedTest").Visible = False) ==============================================================
If myProducts IsNot Nothing And myProducts.Count > 0 Then Me.DataList1.DataSource = n Me.DataList1.DataBind()
Dim display As Integer = SettingsManager.GetIntegerSetting("LPVDisplayTypeRad").ToString
If display = 0 Then Me.DataList1.RepeatDirection = RepeatDirection.Horizontal Me.DataList1.RepeatColumns = SettingsManager.GetIntegerSetting("LPVGridColumnsField") ElseIf display = 1 Then Me.DataList1.RepeatDirection = RepeatDirection.Vertical Me.DataList1.RepeatColumns = SettingsManager.GetIntegerSetting("LPVDisplayTypeRad") Else Me.DataList1.RepeatDirection = RepeatDirection.Horizontal Me.DataList1.RepeatColumns = 3 End If
Else Me.FindControl("RecentlyViewedTest").Visible = False
End If
========================
Then everything should work fine. Obviously you can name the id anything you want. Nice catch! |
|
|
|
|
Rank: Member
Joined: 7/15/2004(UTC) Posts: 368
|
That works beautifully! Thanks Brendon and Corneliu!
BV - would you consider adding this to SP3? That way everyone would get the fix and I don't have to keep adding it to every site I do. What Brendon added hides the <h4> tag. Without the extra code to the view.ascx, the background image was still showing up even if there was no content. |
|
|
|
|
Rank: Member
Joined: 9/27/2004(UTC) Posts: 1,099
|
I will add it to the SP3 suggestion list. |
|
|
|
|
Rank: Member
Joined: 1/3/2004(UTC) Posts: 1,497
|
I noticed that if a product is deleted from the store, the Recently Viewed items still shows the product when you return to the homepage. Clicking on the link gives you a "resource not found" error. Refreshing the browser doesn't help. Starting a new session, does correct the issue. |
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.