belwarg Posted July 16, 2013 Share Posted July 16, 2013 Hello! I want to add list of all articles from one category to module. It is possible just by adding some code in tpl, or I have to add also something to php files of this module? And how to get all articles from one category in Prestashop? Link to comment Share on other sites More sharing options...
vekia Posted July 16, 2013 Share Posted July 16, 2013 where you want to display the products? in back office? front office? you have to use CMS object Link to comment Share on other sites More sharing options...
belwarg Posted July 16, 2013 Author Share Posted July 16, 2013 (edited) I want to display list of all cms pages from one, choosen, cms category. By list I mean something like <ul class="bullet"> {foreach from=$cms_pages item=cmspages} <li> <a href="{$link->getCMSLink($cmspages.id_cms, $cmspages.link_rewrite)|escape:'htmlall':'UTF-8'}">{$cmspages.meta_title|escape:'htmlall':'UTF-8'}</a> </li> {/foreach} </ul> But to display this in .tpl file I have to get date from database first, and I don't know how to write query and where (as I have assing result to variable). Module will be placed in front office, in right column. Edited July 16, 2013 by belwarg (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted July 16, 2013 Share Posted July 16, 2013 you can use this code: {foreach from=CMS::getCMSPages(1,1,true) item=cmspages} <li> <a href="{$link->getCMSLink($cmspages.id_cms, $cmspages.link_rewrite)|escape:'htmlall':'UTF-8'}">{$cmspages.meta_title|escape:'htmlall':'UTF-8'}</a> </li> {/foreach} 1 - id language 1 - id of parente category true - only "active" pages 4 Link to comment Share on other sites More sharing options...
belwarg Posted July 16, 2013 Author Share Posted July 16, 2013 Thanks, works like a charm Link to comment Share on other sites More sharing options...
vekia Posted July 16, 2013 Share Posted July 16, 2013 you're welcome im glad that i could help in this case thread marked as [solved] regards Link to comment Share on other sites More sharing options...
jona_46 Posted September 8, 2013 Share Posted September 8, 2013 you can use this code: {foreach from=CMS::getCMSPages(1,1,true) item=cmspages} <li> <a href="{$link->getCMSLink($cmspages.id_cms, $cmspages.link_rewrite)|escape:'htmlall':'UTF-8'}">{$cmspages.meta_title|escape:'htmlall':'UTF-8'}</a> </li> {/foreach} 1 - id language1 - id of parente category true - only "active" pages Spot on, thanks! Link to comment Share on other sites More sharing options...
Minfe Posted April 10, 2014 Share Posted April 10, 2014 Hi everyone!Is it possible to do the same thing with categories? I need to get list of categories in form of <li> I would be grateful for any help you could give me Minfe Link to comment Share on other sites More sharing options...
vekia Posted April 10, 2014 Share Posted April 10, 2014 hello you need list of all available categories in your shop? or only certain of them? Link to comment Share on other sites More sharing options...
Minfe Posted April 11, 2014 Share Posted April 11, 2014 hello you need list of all available categories in your shop? or only certain of them? Thank You for your reply. I need list of all categories. Link to comment Share on other sites More sharing options...
Minfe Posted April 17, 2014 Share Posted April 17, 2014 Nobody knows? Link to comment Share on other sites More sharing options...
vekia Posted April 17, 2014 Share Posted April 17, 2014 hello i missed your reply, im sorry let's clarfiy you mean CMS page category, or catalog category tree? Link to comment Share on other sites More sharing options...
Assramm (cz) Posted October 26, 2016 Share Posted October 26, 2016 (edited) Spot on, thanks! you can use this code: {foreach from=CMS::getCMSPages(1,1,true) item=cmspages} <li> <a href="{$link->getCMSLink($cmspages.id_cms, $cmspages.link_rewrite)|escape:'htmlall':'UTF-8'}">{$cmspages.meta_title|escape:'htmlall':'UTF-8'}</a> </li> {/foreach} 1 - id language1 - id of parente category true - only "active" pages Hello all, please, can you help me upgrade code up for multi-language store? (after switching between languages, names of articles are still in language id 1, links too) I tried to replace language id by ({$id_lang}) to fill this ID automaticly, but it is not working:/ (Im not PHP skilled) ... Seccond thing is, please is possible show small part of content to? I have PS v1.6. Thank you very much, Jiri. Edited October 27, 2016 by Assramm (cz) (see edit history) Link to comment Share on other sites More sharing options...
Assramm (cz) Posted October 28, 2016 Share Posted October 28, 2016 Nobody knows pls? Link to comment Share on other sites More sharing options...
juliyvchirkov Posted December 26, 2016 Share Posted December 26, 2016 (edited) Nobody knows pls? afair when presta is running shop in ml env, to process things it applies current language of active visitor, not the language you're using in your shop backoffice or trying to apply w/ your script moreover, presta all the time is pedantically tracking the settings of each visitor, & it restores the «correct» language (i.e. the language chosen by visitor || applied in shop fe by default) as far as the core gets the control back from your module while developing some module you can easily & quickly retrieve visitor's language (along w/ bunch of other cool & useful things, btw) anytime you'll need to apply it in your code from Context object just init it once at the startpoint $context = Context::getContext(); & then use when needed, like $langID = $this->context->language->id; or $customerID = $this->context->customer->id; et cetera in addition to my comment I'd also recommend to review the official developer's guide on Context object hope it helps Edited December 26, 2016 by juliyvchirkov (see edit history) 1 Link to comment Share on other sites More sharing options...
Assramm (cz) Posted December 27, 2016 Share Posted December 27, 2016 Many thanks to juliyvchirkov. But few days ago I find another solution wich works too for me: {foreach from=CMS::getCMSPages({$cookie->id_lang|intval},3,true) item=cmspages} This change language corrertly and so works for me well! Link to comment Share on other sites More sharing options...
vekia Posted December 27, 2016 Share Posted December 27, 2016 im not sure at the moment, but $cookie variable may not exists everywhere, only on selected page types. Link to comment Share on other sites More sharing options...
Assramm (cz) Posted December 27, 2016 Share Posted December 27, 2016 im not sure at the moment, but $cookie variable may not exists everywhere, only on selected page types. Oh, thank you Vekia! Im using it in homepage only (I tryed to use this code in footer, and it was working too) ..so I realized, that it is working correctly:/ .. Ok, I will test it better in some new project;) Thank you! Link to comment Share on other sites More sharing options...
melissag198510 Posted January 12, 2017 Share Posted January 12, 2017 Hi, i also need some help if anyone can help. I have bought a prestashop template so i am only familar with the control panel and not how to edit code etc :-l my site is up and running with several categories live on the top bar menu. i now need to create a gallery only page also accessible from the top menu bar, so it appears like a category. I have created the category ready it is visible on the menu. I have purchase and installed module 'unite gallery' and have the shortcode to be able to add to a page content. I have tried this through hooks but i can only hook it top, left, right, or bottom positions so not been successful. I then created a CMS page (alongside my others, such as t&c, privacy, contact us etc) for the gallery but it isnt showing in the footer of the page with the others so i cant check if the shortcode i put in the page content is working!! any ideas why it is not displaying, everything is the same as my other CMS pages? If i get this new CMS gallery page to display, is it then possible to get it to the top mega menu? this is really where i need it to be displayed. apologies for my lack of knowledge and terminology i really am a very very basic learner. thanks in advance melissa Link to comment Share on other sites More sharing options...
melissag198510 Posted January 13, 2017 Share Posted January 13, 2017 hi, ive sussed it...yayyy!! thanks x x Link to comment Share on other sites More sharing options...
Poehnixzz Posted May 17, 2021 Share Posted May 17, 2021 Hello, Do you have a solution for 1.7.6.9? The link is working correctly, but {$cmspages.meta_title|escape:'htmlall':'UTF-8'} part is not working. I hope there is a solution for this in 1.7.6.9😃 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