kingsinnersoul Posted June 25, 2013 Share Posted June 25, 2013 Hello, I am tring to have two different views which change on button click. I want to display different title width for each view. I know I can do the following in JS {literal} <script type="text/javascript"> if ($('ul#product_list').hasClass('GRID_VIEW')){ {$product.name|escape:'htmlall':'UTF-8'|truncate:35:'...'}</a></h3> } else if ($('ul#product_list').hasClass('LIST_VIEW')){ {$product.name|escape:'htmlall':'UTF-8'|truncate:75:'...'}</a></h3> } </script> {/literal} but id did not display the title at all. Is there a way to use smarty in order to achieve the above desired result? THANK YOU. Link to comment Share on other sites More sharing options...
kingsinnersoul Posted June 26, 2013 Author Share Posted June 26, 2013 Anyone got any idea on how to do it? Link to comment Share on other sites More sharing options...
kingsinnersoul Posted June 30, 2013 Author Share Posted June 30, 2013 Any maybe someone knows? Link to comment Share on other sites More sharing options...
kingsinnersoul Posted July 1, 2013 Author Share Posted July 1, 2013 **bump** Link to comment Share on other sites More sharing options...
PascalVG Posted July 1, 2013 Share Posted July 1, 2013 No experience with it, but can't you use php function get_class($classVariable) here?? Other option might be to just to create a var that holds the status of the viewtype and toggle it when pressing the button, as well as truncate according to ViewType equals 0 (i.e. Gridview) or 1(i.e. listview) My 2 cents, pascal Link to comment Share on other sites More sharing options...
PascalVG Posted July 1, 2013 Share Posted July 1, 2013 Other option might be to fix it in css: http://stackoverflow.com/questions/8818495/how-can-i-truncate-long-texts-in-a-table-using-css My 2 more cents, pascal Link to comment Share on other sites More sharing options...
kingsinnersoul Posted July 1, 2013 Author Share Posted July 1, 2013 I kinda solved it by using something as follows: [/size] <div class="grid_checker"> {if $subcategory.description} <p class="cat_desc">{$subcategory.description|truncate:250}</p> {/if} </div> <div class="list_checker"> {if $subcategory.description} <p class="cat_desc">{$subcategory.description}</p> {/if} </div> the parent DIV was changing class if it was grid or list. And then in css I added that grid_checker or list_checker was set to display:hidden or display:block... It does the trick - but it is not efficient as it calls twice for the same thing. I just wanted somehow to add the "truncate:250" if the parent div has class or not. oh well... (thanks for the cents :-) Link to comment Share on other sites More sharing options...
PascalVG Posted July 2, 2013 Share Posted July 2, 2013 I'll mark the post as solved then. Happy selling! pascal Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now