Jump to content

[solved] Add CMS to home body content? How?


Recommended Posts

My first post here guys so take it easy on me ;)

 

I'm trying to figure out how to add content to the homepage. I was thinking there would/should be a module for this that would pull in a CMS article but I'm not seeing one.

 

Thanks,

Don

Link to comment
Share on other sites

I'm using PrestaShop™ 1.5.4.1 THANKS!

 

thanx, so here is a code:

 


this is modified hookDisplayHome function in the homefeatured.php file located in modules / homefatured / directory

public function hookDisplayHome($params)
{
 $this->cms = new CMS(3, $this->context->language->id);
 $category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id);
 $nb = (int)(Configuration::get('HOME_FEATURED_NBR'));
 $products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10));
 $this->smarty->assign(array(
	    'cms' => $this->cms,
  'products' => $products,
  'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
  'homeSize' => Image::getSize(ImageType::getFormatedName('home')),
 ));
 return $this->display(__FILE__, 'homefeatured.tpl');
}

 

i added there:

 

$this->cms = new CMS(3, $this->context->language->id);

where "3" is a ID of cms page you want to show;

 

also I added to the array() this variable:

'cms' => $this->cms,

 

 

now go to the homefatured.tpl file and use the:

 

{$cms->content}

 

the effect:

 

fR9uYtV.png

Link to comment
Share on other sites

Thanks vekia! I'm going to actually attempt to create a module that does this and uses the hookDisplayHome. It seems like it would be best to do that rather than hook into an existing module. Because if I'm right, won't my work get lost when I update my install of Prestashop and that module is part of the update?

Link to comment
Share on other sites

Thanks vekia! I'm going to actually attempt to create a module that does this and uses the hookDisplayHome. It seems like it would be best to do that rather than hook into an existing module. Because if I'm right, won't my work get lost when I update my install of Prestashop and that module is part of the update?

 

You've got right, its better to create separate module. It will works always, even after updates :-)

Link to comment
Share on other sites

WooHoo! I did it! Thanks Vekia for showing me the way. So how do I share this new module?

 

create new thread in correct forum subsection (free modules), thats all :-)

I marked this thread as solved

 

regards

  • Like 1
Link to comment
Share on other sites

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...