PDA

View Full Version : Best Seller/New Products


RuralWeb
09-Jul-2006, 10:02 PM
When best seller/new products are displayed in the side bar then the text from the product description is also shown. If the product description is more than a few words then the text dispalyed is excessive and if there are several products showing it looks stupid. What is needed is a short product description field which can be used to enter text that is shown when the product is displayed in the side bar or a text limit that cuts the text at say 10 words.

We all need long product descriptions to generate the food for the search engines, single product pages can have huge descriptions.

NormanRouxel
10-Jul-2006, 12:15 AM
I believe that Variables can now contain a lot of text.

So just create one (e.g. BriefDescription) and use it instead of the ProductDescription one in the Layout Code - Mini Product Description.

Here's a walkthrough on doing just that.

Go to Design / Library / Variables and highlight Product.

Now right click and choose New Variable.

At Basic Definition set the following

Name: BriefDescription

Description: Some brief text for the marketing thumbnails.

Prompt: Brief Description

Place Of Setting: Product

Allow <Use Parent> as an Option: Unchecked

leave all other settings as is.
OK out.

Now click the main Design View tab and make sure that the Layout code tab at the bottom is also selected. Click the [><] Icon (just top left of layout window) so that it has an orange background - this gives you the concise view.

Click within one of the sidebar products. The Layout Code Window should be titled Layout Code - Mini New Product Item.

Look in that code for the fragment ProductDescription and right-click it - it should turn grey and an options window should appear.

Choose Insert Variable. Navigate to BriefDescription and Insert it.

That's it. Your Products will now have a Property tab where you can enter the Brief Description for these sidebar items.

zmagyar
10-Jul-2006, 10:46 AM
What is needed is a short product description field which can be used to enter text that is shown when the product is displayed in the side bar or a text limit that cuts the text at say 10 words.
The first point can be solved as Norman described above. But the second point can also be done in v8. v8 supports PHP for offline page generation. So you can write a small bit of PHP which cuts the text for you. Just create a new BLOCK tag in the markup and right click to edit its appearance. You will find a PHP item in the grid. If you change it to TRUE then the block's content will be evaluated as a PHP script during page rendering. You can use the Actinic variables in this PHP block just like everywhere in the markup (but the selectable flag is required for these variables). E.g. if you change the variable ProductDescription to the code below then the description will be cut after 10 words.
<actinic:block php="true" >
$sShort = "";
$nCount = 0;
$sOriginal = "<actinic:variable encoding="perl" name="ProductDescription" selectable="false" />";
foreach(explode(" ", $sOriginal) as $sWord)
{
if ($nCount > 10)
{
$sShort .= "...";
break;
}
$sShort .= $sWord . " ";
$nCount++;
}

echo $sShort;
</actinic:block>

NormanRouxel
10-Jul-2006, 11:02 AM
Hi, Zoltan

I noticed those php=true tags. I wondered what they were for - nothing in the Help as yet.

Now if I read this right, you've embedded a PHP interpreter into the Actinic executable so that we can process variables and generate code at page compile time.

If that's correct I'm going to have a lot of fun with that.

This is a great example of V8 adding not just a little extra functionality but a whole lot of unexpected capability.

cdicken
10-Jul-2006, 12:14 PM
nothing in the Help as yetThat will all be in the Advanced User Guide - as soon as I get around to writing it.....

zmagyar
11-Jul-2006, 10:36 PM
Now if I read this right, you've embedded a PHP interpreter into the Actinic executable so that we can process variables and generate code at page compile time.
You are correct, that's the case. Originally we have embedded the PHP engine into Catalog for the flexibility of the condition evaluation (yes you can use arbitary PHP expressions in the conditions). Later it was extended to the page generation by having the PHP attribute on the BLOCK tags. You can find examples of its usage in the company logo size, the price format and the push button grid layouts in the default DB. Those are really just very limited examples. This feature provides lot more power IMO. I've got a few more complex ideas to present the flexibility of this feature (like thumbnail image generation on the fly) but nearly at the end of v8 development we got much bigger fish to fry.
If that's correct I'm going to have a lot of fun with that.
Good luck with that. I'm already seeing the great extensions coming from you. :-)

pinbrook
11-Jul-2006, 11:10 PM
(like thumbnail image generation on the fly)

yes please

RuralWeb
11-Jul-2006, 11:12 PM
Thanks for the replies about the shortened text guys - bit late as I missed the posts.

NormanRouxel
12-Jul-2006, 08:44 AM
(like thumbnail image generation on the fly)
I just stuck this into a Layout

<actinic:block php="true" >
phpinfo();
</actinic:block>

and sure enough got the full PHP configuration display.

Good to see that the GD image library is in there. That means that dynamic image generation at page compile time should be easy.

Now I just need to figure out how I can add this newly created image to the list of files to upload. Any ideas?

cdicken
12-Jul-2006, 08:58 AM
Now I just need to figure out how I can add this newly created image to the list of files to upload. Any ideas?Just to recap - is this an image that is created on the fly? Will you know the filename of the image in advance?

cdicken
12-Jul-2006, 09:30 AM
Ahh - hang on. Upload has changed in v8 and now Actinic generates the entire site and works out everything it needs to upload, and then uploads it - so any files generated during site generation should be picked up.

RuralWeb
12-Jul-2006, 09:35 AM
works out everything it needs to upload, and then uploads it - so any files generated during site generation should be picked up. Good news. I presume that this will work for images that are contained in an outer layer created and registered in DW. Do the images have to be in the root directory of site 1 or can they be in a folder within site 1 and still get picked up.

cdicken
12-Jul-2006, 09:40 AM
As far as I know, it's every single file mentioned anywhere in the site.

zmagyar
12-Jul-2006, 10:37 AM
Now I just need to figure out how I can add this newly created image to the list of files to upload. Any ideas?
As Chris has mentioned correctly this bit was also changed in v8. All the files referenced in the HTML source are automatically picked up and added to the list of files to be uploaded. Therefore if you create a link to the thumbnail image then it will automatically uploaded (if found on the disk).
Good to see that the GD image library is in there.It was required for the image size example. But the list of included libraries can be extended by editing php.ini in the Actinic installation folder. However the list of included libraries should be extended carefully because it may have significant effect on the engine initialisation performance.
If you are developing functions which are used frequently then you can include them in actinic_main.php which is included all the time when the engine started. However instead of direct inclusion I would suggest your custom code to be in a separated file which is included in actinic_main.php (this will save some time on merging when Actinic changes actinic_main.php).
Do the images have to be in the root directory of site 1 or can they be in a folder within site 1 and still get picked up.This function deals with both relative and absolute paths. If you can't wait experiencing it until the Advanced User Guide is out I would suggest to test it yourself by using the "Insert File Name" context menu in the code editor.

dazzerb
14-Jul-2006, 07:09 AM
The first point can be solved as Norman described above. But the second point can also be done in v8. v8 supports PHP for offline page generation. So you can write a small bit of PHP which cuts the text for you. Just create a new BLOCK tag in the markup and right click to edit its appearance. You will find a PHP item in the grid. If you change it to TRUE then the block's content will be evaluated as a PHP script during page rendering. You can use the Actinic variables in this PHP block just like everywhere in the markup (but the selectable flag is required for these variables). E.g. if you change the variable ProductDescription to the code below then the description will be cut after 10 words.
<actinic:block php="true" >
$sShort = "";
$nCount = 0;
$sOriginal = "<actinic:variable encoding="perl" name="ProductDescription" selectable="false" />";
foreach(explode(" ", $sOriginal) as $sWord)
{
if ($nCount > 10)
{
$sShort .= "...";
break;
}
$sShort .= $sWord . " ";
$nCount++;
}

echo $sShort;
</actinic:block>

sorry I am being thick here but could you talk me through how to do this in laymans terms please. Where exactly do I find the markup that I need to insert the block / code into and where do I find the variable ProductDescription

Thanks in advance.

Jan
14-Jul-2006, 08:47 AM
Go to the design tab, click on one of the new product descriptions and the window at the bottom of the screen will show the markup code - when I did this, product description was highlighted, so I just deleted it and pasted Zoltan's code into it's place. Job done.

That is why it is easier to make changes to the design with V8, you can just go to the design tab, click on whatever you want to change and just type in your changes. Then you see the changes right away in the top window and so can review them if you wish.

Regards,

Jan
14-Jul-2006, 08:58 AM
That was my first attempt at changing the design with V8 - I'm feeling very pleased with myself :D

Regards,

dazzerb
14-Jul-2006, 10:50 AM
Hi Jan,

thanks for that, it worked!! :D

Regards Darryl

dscontroller
14-Jul-2006, 07:19 PM
Hi Jan,

I've also just tried this little trick and found that it worked. It's the only trick that has worked for me up to the now, so like you, feeling a little more pleased!!

I think that it is easy to manipulate the store using what is provided, but I suppose most of us want to do more unique offerings.

David

cdicken
17-Jul-2006, 10:01 AM
I think that it is easy to manipulate the store using what is provided, but I suppose most of us want to do more unique offerings.The whole 'big idea' behind v8 is that it has changed design from being a rigid set of templates to being a flexible ecommerce toolkit where you can define your own designs and rules. Over the coming months there will be lots of little tricks and fixes published that you can use for your site design to help you create something unique.

jont
31-Jan-2007, 02:30 PM
Is there any way to preserve line breaks that appear in the full description in the shortend description? Eg: the full product shows :

Text 1
Text 2
Text 3 here with full blurb

.. using the PHP by Zoltan it loses the line breaks to:

Text 1 Text 2 Text 3 here with full blurb. Can the 3 line format be retained?

dave_finlayson
31-Jan-2007, 02:37 PM
Jont,

Try changing the Encoding from 'HTML' to 'Leave as Is'

jont
31-Jan-2007, 02:41 PM
Dave - I don't see that in that block of code?

dave_finlayson
31-Jan-2007, 02:46 PM
Ooops. Encoding should be changed from Perl, not html, i.e:-

$sOriginal = "<actinic:variable encoding="perl" name="ProductDescription"

should become:-

$sOriginal = "<actinic:variable encoding="actinic" name="ProductDescription"

jont
31-Jan-2007, 02:51 PM
Aha .. I see ... it is in the appearance of selector .. setting to "leave as is" works a treat.

Go straight to top of class Mr Finlayson

dave_finlayson
31-Jan-2007, 02:58 PM
There's somewhere I have never been before!!!!

jont
31-Jan-2007, 04:52 PM
I was usually at the back facing the wall :o

leehack
31-Jan-2007, 05:05 PM
Was that to stop you sticking the desk together with chewing gum?

bentleybloke
31-Jan-2007, 10:47 PM
<actinic:block php="true" >
$sShort = "";
$nCount = 0;
$sOriginal = "<actinic:variable encoding="perl" name="ProductDescription" selectable="false" />";
foreach(explode(" ", $sOriginal) as $sWord)
{
if ($nCount > 10)
{
$sShort .= "...";
break;
}
$sShort .= $sWord . " ";
$nCount++;
}

echo $sShort;
</actinic:block>

Is there a way of stopping html embedded in the product description from showing? If the description contains !!<<strong>>!!TEXT!!<</strong>>!! at the beginning for instance, this shows up in the marketing description complete with !!< etc.

Thanks!

NormanRouxel
31-Jan-2007, 11:47 PM
Above the line

foreach(explode(" ", $sOriginal) as $sWord)

add

$sOriginal = preg_replace('/\!\!<|>\!\!/', '', $sOriginal); // remove!!< and >!!
$sOriginal = preg_replace('/<.*?>/', '', $sOriginal); // remove any HTML tags

NB untested, so be prepared to fix typos.

bentleybloke
03-Feb-2007, 08:18 PM
Thank you Norman, works perfectly as is.

stuartn
04-Feb-2007, 01:36 AM
That's it. Your Products will now have a Property tab where you can enter the Brief Description for these sidebar items.

I've added a new variable to store a brief description of a product, and I have added it to the New Products section it places as the default Home page when you start a new site in v8 (we only want to show the product title in the side bar New Products).

But, I can;t see where to actually type in the brief description? Should it be within the Property tab of the product? Do i need to do something to update this?

Cheers,

Stuart

pinbrook
04-Feb-2007, 03:02 PM
have you created the variable as shown by Norman in post #2

stuartn
05-Feb-2007, 11:21 AM
Yeah - followed his instructions and added a Variable in the Product section as he described. But when i go into the UI, theres nothing new that i can see for populating that variable.

cdicken
06-Feb-2007, 09:24 AM
Yeah - followed his instructions and added a Variable in the Product section as he described. But when i go into the UI, theres nothing new that i can see for populating that variable.What settings do you have under 'Place of Setting' for the 'BriefDescription' variable?

What box is ticked, and what is the 'Tab Name' set to?

stuartn
06-Feb-2007, 02:32 PM
Oops :-)

Sorry Norman, I didn't tick the Product check box in Place of Setting.

Thanks for everyones help.

skinnybloke
08-May-2007, 11:46 AM
Hi - this code works great until you have quotes or double quotes in the description. Then it fails with Parse error: parse error in main on line 4.

I tried using addslashes but to no effect. I could always use preg_replace to replace the quotes with NULL's but has anyone got a cuter way so that the quotes are still displayed?

skinnybloke
08-May-2007, 12:18 PM
aaahhh - I did not look hard enough. I found the answer here:

http://community.actinic.com/showthread.php?t=23732&highlight=foreach%28explode%28+%2C+%24sOriginal%29+as+%24sWord%29

NigelRS
12-Aug-2008, 07:14 PM
I so much want to get this to work, but I feel stupid. I have had a look at the suggestion in posting 2.

I have gone on and created the Variable. I ticked Product for the choice and left the tab as as Properties as no Tab selection was given.

I then clicked on the Design tab, selected a Product from the Content tree and has a look at the Layout Code, but at no point could I find ProductDescription for me to put something in to replace.

I am using v8.5.

Can someone please advise me as my descriptions are long on some items and brief on others, so the site looks all lop-sided.

www.serenitysounds.co.uk

Thanks!

Nig

leehack
12-Aug-2008, 07:45 PM
Open your product layout in the design-library instead then, i suspect that you was not actually looking at your product layout in the design tab.

NigelRS
13-Aug-2008, 02:32 PM
Thanks.

Looking again I found the ProductDescription variable and replaced it with the BriefDescription variable and applied it.

I saw that the products had no description in them whatsoever and when I went to a product description, I clicked on the Properties tab, noticed that there was a Product - Brief Description but could find no place to enter a brief description for it to display, nor could I see where the full description could then be displayed (not unless the assumption is made that the full description is put in a pop up box/extended information box.

As for the block php script cutting it down to 10 words....that link implies a working knowledge of blocks and the AUG doesn't really cover blocks in any capacity.

Can someone please advise on how/where I enter my copy for the Brief Description on the products (also how I get the Brief Description to work with the New Products/Best Sellers).

gabrielcrowe
13-Aug-2008, 04:42 PM
the AUG doesn't really cover blocks in any capacity.
Yes, you're right, becasue its an Advanced user guide, this implies that you're in ownership of at the very least, a basic skill set.

I'd suggest a jolly good read of the manual.

Followed by this tutorial:
http://community.actinic.com/showthread.php?t=35126

The notion we're talking about is akin to extending the basic functionality of the catalog. Its a simple case of adding a variable, on a per products basis. After you read the offending media, you'll find that its a breeze, and you'll want to show people at parties, etc.

Good luck!