Author |
Topic |
|
unitedowners
Starting Member
Romania
16 Posts |
Posted - October 14 2006 : 00:07:35
|
Hi guys!
I want to customize the look of shopdisplayproducts.asp by displaying 200 characters of extendeddesc instead of cdescription. mention that i`m using tmp_productformat.htm for shopdisplayproducts. Also some text from extendeddesc has tables so i think i will need something like shopdynamictitle from shopheaders. I`ve tryied different code lines in shopproductformat_templates but i couldn`t find a way to limit the text to display. Can u give me some help?
Thank you! |
|
devshb
Senior Member
United Kingdom
1904 Posts |
Posted - October 14 2006 : 04:55:00
|
You'd need to create a new template-field for that, as you can't put vbscript code into the templates.
For example, if you want to show the first 200 characters, and then add "... more" to the end and a link on it to the detail page if it's over 200 characters, then you'd create a new template field which does all that, and then call it from your template with something like:
[CUSTOMISED_SUMMARY_DESCRIPTION catalogid]
When we do this kind of thing, we use our "extra-template-fields" addon as it keeps all the logic in easily tweaked separate files etc. If you want that, see: http://www.bigyellowzone.com/shopexd.asp?id=42
However, please note that that addon comes free/included with some of our other addons, so have a look at the template-field addons mentioned here first to see if you'd also like any of those: http://www.bigyellowzone.com/softwareversions.asp#BYZ034S if you want any of those template-field addons then byz033 (the generic extra-template-fields addon) will come with it.
the kind of vbscript logic you'd need might be something like this:
if (arg_in_val="" or IsNull(arg_in_val)=true) then outdesc="" else if (Len(arg_in_val)>200) then outdesc=Left(arg_in_val,200)&" ..." else outdesc=arg_in_val end if end if
you can add template-fields to your shopfileio.asp file directly if you don't want the byz033 addon, it's just that we prefer byz033 as it keeps things separate and easy to tweak/find/add.
if using html within the description, then you'd need to do the kind of thing you mentioned above; strip-out the html to return the raw text, and then check that length, and then do a replace on it.
does anyone else need this kind of thing? the final code might end up quite complex, but if there's a call for it then we could code it up as an addon.
while on the subject; I'm curious; has anyone here ever created a template-field with more than 1 argument? eg: [LTRIM_VAL 200 extendeddesc]
Simon Barnaby Developer [email protected] www.BigYellowZone.com Web Design, Online Marketing and VPASP addons |
Edited by - devshb on October 14 2006 05:07:39 |
|
|
unitedowners
Starting Member
Romania
16 Posts |
Posted - October 14 2006 : 14:40:49
|
Thanks for support Simon!
i allready have byz033 addon, i`ve created the template field and now i`m trying to impplement the code you gave me to the template codes functions. It`s a little too complex for me but i hope i will succeed. I`ll write back the result |
|
|
unitedowners
Starting Member
Romania
16 Posts |
Posted - October 14 2006 : 18:12:09
|
Ok...i can`t make it work. I need some help here:
Sub CUSTOMISED_SUMMARY_DESCRIPTION(arg_inval) Dim outdesc if (arg_in_val="" or IsNull(arg_in_val)=true) then outdesc="" else if (Len(arg_in_val)>200) then outdesc=Left(arg_in_val,200)&" ..." else outdesc=arg_in_val end if end if End sub
what is missing?
Thank you! |
|
|
devshb
Senior Member
United Kingdom
1904 Posts |
Posted - October 15 2006 : 04:35:03
|
if using byz033, then using example4 (defined in byz_template_codes_functions_example4.asp and byz_template_codes_codes_example4.asp) as an example/trial, you'd change the first function to this in byz_template_codes_functions_example4.asp:
Sub BYZ_EXAMPLE4_ARGS_MAIN(arg_out_value,arg_in_value) if (arg_in_value="" or IsNull(arg_in_value)=true) then arg_out_value="" else if (Len(arg_in_value)>200) then arg_out_value=Left(arg_in_value,200)&" ..." else arg_out_value=arg_in_value end if end if End Sub
and to call it, you'd use: [BYZ_EXAMPLE4_ARGS extendeddesc]
(ie note that the function has an outward argument supplied to it, as well as an inward one)
Simon Barnaby Developer [email protected] www.BigYellowZone.com Web Design, Online Marketing and VPASP addons |
Edited by - devshb on October 15 2006 04:44:14 |
|
|
unitedowners
Starting Member
Romania
16 Posts |
Posted - October 15 2006 : 10:35:25
|
Thanks Simon!
It`s working great:
The final code is:
Sub BYZ_EXAMPLE4_ARGS_MAIN(arg_out_value,arg_in_value) if (arg_in_value="" or IsNull(arg_in_value)=true) then arg_out_value="" else if (Len(arg_in_value)>200) then arg_out_value=Left(Removehtmlheaders(arg_in_value,"<br>"), 200)&" ..." else arg_out_value=arg_in_value end if end if End Sub |
|
|
Mark Priest
VP-CART Expert
United Kingdom
580 Posts |
Posted - January 11 2007 : 20:46:16
|
Hi Guys,
Im trying to replicate exactly what you have done above, but I just cant get my head around it all.
Can one of you two walk me through it? I have installed the template addon and tried to follow the instruction here, but with no success.
Can you help?
Regards,
Mark |
|
|
Mark Priest
VP-CART Expert
United Kingdom
580 Posts |
Posted - January 11 2007 : 20:59:27
|
Hi Guys,
I've worked it out! Thanks.
Regards,
Mark |
|
|
Joff
Starting Member
United Kingdom
43 Posts |
Posted - January 12 2007 : 03:01:13
|
The code above could end mid-word. If anyone's interested, here's an example I've borrowed from the Codeproject site (http://www.codeproject.com/asp/textpreview.asp and adapted it with just one argument (as I didn't know the answer to Simon's question on multiple args :))
This code will end on a full word, adding "more..." to the end.
Change nChars and sMoretext values to your needs.
Function TextPreview(strText)
Const nChars = 200
Const sMoretext = " more..."
Dim nPos
' Uncomment next line to replace line breaks with spaces
' strText = Replace(strText, vbCrLf, " ")
' Check if it's longer than limit
If Len(strText) > nChars And nChars > 4 Then
' Find the end of last whole word that we can use
nPos = InStrRev(Left(strText, nChars - 3), " ")
If nPos > 0 Then
' Take whole words only
TextPreview = Left(strText, nPos) & sMoretext
Else
' No spaces were found - take what we can
TextPreview = Left(strText, nChars - 4) & sMoretext
End If
Else
' Take nChars from the text
TextPreview = Left(strText, nChars)
End If
End Function
|
Edited by - Joff on January 12 2007 03:12:37 |
|
|
Mark Priest
VP-CART Expert
United Kingdom
580 Posts |
Posted - January 12 2007 : 22:09:33
|
Hi Joff,
Where did you put this code?
Regards,
Mark |
|
|
Joff
Starting Member
United Kingdom
43 Posts |
Posted - January 15 2007 : 03:18:42
|
Hi Mark,
I've not implemented any of my own code yet (I'm just finding my way around VPASP :)
I believe shop$db.asp is the preferred location for the code or even at the end of shopdisplayproducts.asp will be fine.
Again, someone correct me if I'm wrong but I think the Sub "ProductGetValues" in shop$db.asp is used to get the data you want.
Modify the line memcdescription = objrs("cdescription") to
memcdescription = TextPreview(objrs("cdescription"))
If you're using extendeddesc, then modify the other line instead (my version of VPASP has one commented out). |
Edited by - Joff on January 15 2007 03:19:32 |
|
|
Mark Priest
VP-CART Expert
United Kingdom
580 Posts |
Posted - January 21 2007 : 18:51:45
|
Hi Joff
Only one problem I see doing that, is that this would then shorten the description every time you called it in VPASP am I correct?
Regards,
Mark |
|
|
Steve2507
VP-CART Expert
590 Posts |
Posted - July 28 2009 : 12:40:10
|
quote: Originally posted by unitedowners
Thanks Simon!
It`s working great:
The final code is:
Sub BYZ_EXAMPLE4_ARGS_MAIN(arg_out_value,arg_in_value) if (arg_in_value="" or IsNull(arg_in_value)=true) then arg_out_value="" else if (Len(arg_in_value)>200) then arg_out_value=Left(Removehtmlheaders(arg_in_value,"<br>"), 200)&" ..." else arg_out_value=arg_in_value end if end if End Sub
Really sorry to bring up an old thread, but thought that as it was directly related it was the right thing to do.
I've implemented this solution and it is working great.
However what I would really like is for the dots to be the link to the expanded page.
Does anyone have any idea how I pull in the information needed for this?
Thanks
Steve Sex toys from a UK sex shop including vibrators and dildos. |
|
|
|
Topic |
|