Jump to content

[solved] Display cms pages from one cms category


Recommended Posts

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

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 by belwarg (see edit history)
Link to comment
Share on other sites

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

  • Like 4
Link to comment
Share on other sites

  • 1 month later...

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

 

Spot on, thanks!

Link to comment
Share on other sites

  • 7 months later...
  • 2 years later...

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 language

1 - 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 by Assramm (cz) (see edit history)
Link to comment
Share on other sites

  • 1 month later...

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 by juliyvchirkov (see edit history)
  • Like 1
Link to comment
Share on other sites

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

  • 3 weeks later...

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

  • 4 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...