CS-Cart feature values on the list pages - smarty

In CS-Cart how can I get separate feature values in the list views?
In the detail view you can get any feature that is available by doing something like this:
{$product.header_features.1.value}
But in the list views it seems the only way to get features is like this:
{assign var="product_features" value="product_features_`$obj_id`"}
{$smarty.capture.$product_features nofilter}
Which results in a comma separated list wrapped in a div. If the feature is a number it means you end up with a meaningless list of numbers without labels.
Is there any way to have each feature available to the template, so I can add icons before each?

With much investigation I finally found that the line:
{assign var="product_features" value="product_features_`$obj_id`"}
is getting it's information from the file templates/common/product_data.tpl
Looking at that file clearly shows it get features from the file views/products/components/product_features_short_list.tpl
Then to identify each feature all I needed to do was add a wrap in the foreach like this:
<span class="grid-feature feature_{$feature.description|lower|replace:' ':'-' nofilter}"></span>
and CSS can do the rest.

Related

Laravel string limit with html tag shows less item than the actual number of items

I am using laravel and blade to loop over some blog items. I wanted to show blog with html tags and also with str_limit function.
When I try
{!!str_limit($blog->body, 450)!!}
It only shows 10 blogs or 11 out of 22. It should show all items.
If I use {{ str_limit($blog->body, 450) }} it shows all but without html tags I mean no effect of html tag.
str_limit has no knowledge of HTML tags, so using it on a string that contains HTML will often result in an unclosed tag that breaks the rest of the page.
As an example, an excerpt that ends in <a href="http://google.co because it got lopped off there means the rest of your page is part of the <a> tag until you accidentally output a " and a > again.
A couple options are available to you:
Strip the HTML tags. I know you wanted to preserve them, but this remains the easiest way of generating an excerpt.
Output the entire body, but give it max height and an overflow: hidden to hide the rest. This has bandwidth downsides, so if your posts are enormously long, it may not be the best approach.
Produce your own excerpts as a separate field. Manual work, but you're always in control that way.
Find/code a HTML-aware excerpt generator. I'm not aware of a good one I can recommend - it's a complicated problem. You could try generating a str_limited string and then running the results through Tidy, which can sort of fix invalid HTML.

How do I create a numbered paragraph list in Github-Flavored Markdown?

Reading through GitHub's help website, I've come across a very neat-looking procedure list.
From GitHub's Create A Repo Tutorial
I have read through GitHub's Markdown Tutorial as well as the Markdown Cheatsheet, but have not found any way to perfectly replicate this type of format.
The closest I have done so far was to basically put a blockquote after a number list entry:
1. > line 1
>
> line 2
2. > line 3
>
> line 4
And it looks similar, but, well, see for yourself:
Is this the closest I can get to GitHub's format?
Is there a proper Markdown syntax that I have missed?
If not, is there a way to achieve this in raw HTML?
If you look at the source of that page you can see that this is just a normal ordered list containing paragraphs:
<ol>
<li><p>In the upper-right corner of any page, click...
So to produce that HTML with markdown simply use the normal ordered list syntax:
1. First paragraph here.
2. Another paragraph here.
The particular appearance of that page is done by styling with CSS. It looks a little involved, using the ::before pseudo-element. If you want to replicate something similar have a look at the page with your browsers inspector to see the the styles. Experiment until you understand how it works and can create the effect you want.
If you are looking to create this effect on your own Github pages (e.g. a README) then I think you are out of luck, since you can’t control the CSS.

Pinpointing the difference and changes made between two pages in magento 1.6.2

I have two pages that should be using the exact same template and layout.
The correct item layout can be seen below.
http://dokha.co/index.php/medwakh/custom-medwakh-from-white-horse-studios-13.html
The incorrect item layout is below.
http://dokha.co/index.php/shisha-tobacco/al-fakher-shisha-tobacco-1.html
As you can see in the first image the layout of the item is compact. In the second link it is all drawn out.
I am curious to know if you can tell me how to make the second one like the first one, The compact style. I am not sure what modifications could have been made in magento to cause the layout to only show up that way for specific items, as only the items in the category on link 1 behave that way, I would like to know how to make them all behave this way.
Ok, first thing: the layouts are slightly different because in the first example, you have simple product and in the second example you have a configurable product.
So, view.phtml is including different templates in each.
Regardless though, the actually culprit of the expanded space you are seeing in the second example is being caused by a clearing div. Simply remove it.
The div you are looking for is this:
<div class="clearer"></div>
and you will find it in app/design/frontend/your_package/your_theme/template/catalog/product/view.phtml

DataTables - Adding filtering function to a column

I have a table which have information which I would like to exclude from the search box. For example, in one of the columns I have some text and then links, it looks like that:
<td>
<div>John Doe</div>
<div>
View |
Edit |
Delete
</div>
</td>
Of-course in this case I would like the search box to consider only "John Doe" as a text to be searched.
I draw my table in php (I use Symfony-2) and apply the DataTable plugin using dataTable function with jQuery. I got the impression that what I want is possible, but couldn't manage to achieve it. Other discussions like http://www.datatables.net/forums/discussion/255/customising-the-way-the-filter-works/p1 neither helped me to solve this problem.
Thanks!
I'm sure there are ways to customize the actual search function (you could specify the type for the column using mDataProp and then write a custom filter for that type maybe?).
But a different way to go about it is to have your PHP script only supply the name: John Doe. This will be the original data for the cell.
Then in your column definitions, use fnRender() to format the cell using the layout you use in your question -- and have it automatically parse the name to create the links you want (assuming all names are first and last, and all links just use the combined first/last names, this should be fairly easy to implement).
Then set bUseRendered to false for that column and it will perform all of its sorting and filtering based on the original content, not the new content. See more here.

extract xpath

I want to retrieve the xpath of an attribute (example "brand" of a product from a retailer website).
One way of doing it is using addons like xpather or xpath checker to firefox, opening up the website using firefox and right clicking the desired attrbute I am interested in. This is ok. But I want to capture this information for many attributes and right clicking each and every attribute maybe time consuming. Also, the other problem I have is that attributes I maybe interested in will be there for one product. The other attributes maybe for some other product. So, I will have to go that product & then do it manually again.
Is there an automated or programatic way of retrieving the xpath of the desired attributes from a website rather than having to do this manually?
You must notice that not all websites use valid XML that you can use xpath on...
That said, you should check out some HTML parsers that will allow you to use xpath on HTML even if it is not a valid XML.
Since you did not specify the technology you are working with - I'll suggest the .NET HTML Agility Pack, if you need others, search for questions dealing with this here on SO.
The solution I use for this kind of thing is to write an xpath something like this:
//*[text()="Brand"]/following-sibling::*
//*[text()="Color"]/following-sibling::*
//*[text()="Size"]/following-sibling::*
//*[text()="Material"]/following-sibling::*
It works by finding all elements (labels) with the text you want and then looking to the next sibling in the HTML. Without a specific URL to see I can't help any further.
This is a generalised version you can make more specific versions by replacing the asterisks is tag types, and you can navigate differently by replacing the axis following sibling with something else.
I use xPaths in import.io to make APIs for this kind of thing all the time, It's just a matter of finding a xPath that's generic enough to find the HTML no matter where it is on the page, but being specific enough to get the right data.

Resources