PrestaShop Forums: Frontpage Categories Module for v1.3 and below - PrestaShop Forums

Jump to content


Welcome to the PrestaShop Forum! We hope you'll share your comments and suggestions with us. We ask that you please post in English to the main sections of the PrestaShop Forum. If you want to write in another language, please post in the corresponding PrestaShop Community section below.

Please note that PrestaShop Community sections are largely self-moderated. PrestaShop team members may or may not participate in non-English sections. To improve the chances of receiving feedback to your question or comment, please post it in English to the main sections of our Forum.

NYC

Vous parlez français ? par ici !


Frontpage Categories Module for v1.3 and below


Frontpage Categories Module for v1.3 and below

#1 ejectcore

    PrestaShop Addict

  • 08 Apr 2008
  • Members
  • PipPipPip
  • 827 posts
  • Location:UK

Posted 09 May 2008 - 12:18 PM

I have to say this is the first Module for prestashop I have ever created, some of you here may already know how to do this. but for those who don't carry on reading below

Sorry this module is in english only I am no good with module translation  :-
As I progress with learning PrestaShop I will try to share these new Mods  ;)

Frontpage Categories v0.1
Displays categories in the middle of your homepage

Please download then unzip homecategories.zip to the modules directory then upload.

All you have to do then is add the value homecategories to name field & value 1 in to active field within mysql table ps_module then your see the new module in the PrestaShop Admin. (Select hompage possition)

I have not used any styling from global.css so if you wan to use box styling you will need to modify homecategories.tpl

example

change:
<div>
<h4>{l s='categories' mod='homecategories'}</h4>
	{if isset($categories) AND $categories}
<div>


to:
<div id="featured-products_block_center" class="block products_block">
<h4>{l s='categories' mod='homecategories'}</h4>
	{if isset($categories) AND $categories}
<div class="block_content">


Enjoy  :) 



Attached File(s)


Filter Search 2.1 Enterprise Edition Now Available

Available Soon
Filter Search 2.1 Lite Edition

Follow us on twitter

#2 ejectcore

    PrestaShop Addict

  • 08 Apr 2008
  • Members
  • PipPipPip
  • 827 posts
  • Location:UK

Posted 09 May 2008 - 01:57 PM

Quick note: Make sure categories are enabled on the left column for the frontpage categories to work.
Question for the Prestashop Team how do I get this module to work in any position, it seems to only work when categories are displayed on the left column  ???

<?php

class Homecategories extends Module
{
	private $_html = '';
	private $_postErrors = array();

	function __construct()
	{
		$this->name = 'homecategories';
		$this->tab = 'Home';
		$this->version = 0.1;

		parent::__construct(); // The parent construct is required for translations

		$this->page = basename(__FILE__, '.php');
		$this->displayName = $this->l('Frontpage Categories');
		$this->description = $this->l('Displays categories in the middle of your homepage');
	}

	function install()
	{
		if (!Configuration::updateValue('HOME_categories_NBR', 10) OR !parent::install() OR !$this->registerHook('home'))
			return false;
		return true;
	}

	public function getContent()
	{
		$output = '<h2>'.$this->displayName.'</h2>';
		if (Tools::isSubmit('submitHomecategories'))
		{
			$nbr = intval(Tools::getValue('nbr'));
			if (!$nbr OR $nbr <= 0 OR !Validate::isInt($nbr))
				$errors[] = $this->l('Invalid number of categories');
			else
				Configuration::updateValue('HOME_categories_NBR', $nbr);
			if (isset($errors) AND sizeof($errors))
				$output .= $this->displayError(implode('<br />', $errors));
			else
				$output .= $this->displayConfirmation($this->l('Settings updated'));
		}
		return $output.$this->displayForm();
	}

	public function displayForm()
	{
		$output = '
		<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
			<fieldset><legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Settings').'</legend>
				<label>'.$this->l('Number of categories displayed').'</label>
				<div class="margin-form">
					<input type="text" size="5" name="nbr" value="'.Tools::getValue('nbr', Configuration::get('HOME_categories_NBR')).'" />
					<p class="clear">'.$this->l('The number of catgeories displayed on homepage (default: 10)').'</p>
					
				</div>
				<center><input type="submit" name="submitHomecategories" value="'.$this->l('Save').'" class="button" /></center>
			</fieldset>
		</form>';
		return $output;
	}

	function hookHome($params)
	{
		global $smarty;
		$category = new Category(1);
		$nb = intval(Configuration::get('HOME_categories_NBR'));
		
		$smarty->assign(array(
			'category' => $category,
			'lang' => Language::getIsoById(intval($params['cookie']->id_lang)),
		));
		return $this->display(__FILE__, 'homecategories.tpl');
	}

}



Filter Search 2.1 Enterprise Edition Now Available

Available Soon
Filter Search 2.1 Lite Edition

Follow us on twitter

#3 Rain3r

    PrestaShop Apprentice

  • 08 Mar 2008
  • Members
  • PipPip
  • 142 posts

Posted 09 May 2008 - 04:34 PM

I ve done it as you said but nothing new appears on the home page :(

#4 ejectcore

    PrestaShop Addict

  • 08 Apr 2008
  • Members
  • PipPipPip
  • 827 posts
  • Location:UK

Posted 09 May 2008 - 04:48 PM

Make sure you have categories in the left column & inserted the value into the database  8)
& don't forget to upload the homecategories folder into the modules directory

Then if all the above is correct activate it in the admin (Transplant a module)
then Frontpage Categories will appear in the dropdown hook into Homepage Content

Attached File(s)


Filter Search 2.1 Enterprise Edition Now Available

Available Soon
Filter Search 2.1 Lite Edition

Follow us on twitter

#5 Rain3r

    PrestaShop Apprentice

  • 08 Mar 2008
  • Members
  • PipPip
  • 142 posts

Posted 09 May 2008 - 04:50 PM

Maybe that is the problem, when I click on Transplant module, I get only Hack atempt message :(

#6 ejectcore

    PrestaShop Addict

  • 08 Apr 2008
  • Members
  • PipPipPip
  • 827 posts
  • Location:UK

Posted 09 May 2008 - 05:38 PM

Just a thought to activate frontpage categories manually via mysql:

First backup your DB then enter the id you used to setup this module in table ps_module ie. (36 homecategories)
now enter this id into ps_hook module id_module then in the next field enter 8 which is the idhook for home then enter 1 for the possition value

No idea why your getting hack attempt but the above should work. If not fix this issue before using this module
search for forum maybe someone has the same issue if not go back & see what the developers say.

To completely change the subject will RC3 be released in the next few days?


Filter Search 2.1 Enterprise Edition Now Available

Available Soon
Filter Search 2.1 Lite Edition

Follow us on twitter

#7 jolvil

    PrestaShop Fanatic

  • 22 Dec 2007
  • Members
  • PipPipPipPip
  • 2676 posts
  • Location:Paris

Posted 09 May 2008 - 05:47 PM

I've installed this module on a RC2 test shop, it works perfectly.  You can see result at
Categories are dispayed in a single column, it could be nice to be able to choose 1,2,3 or 4... columns on admin.

Thanks for this works

#8 ejectcore

    PrestaShop Addict

  • 08 Apr 2008
  • Members
  • PipPipPip
  • 827 posts
  • Location:UK

Posted 09 May 2008 - 05:53 PM

All you have to do to get your column layout is add some new styles to global.css or set css to the same as the featured module blocks  :)
<div id="featured-products_block_center" class="block products_block">
Filter Search 2.1 Enterprise Edition Now Available

Available Soon
Filter Search 2.1 Lite Edition

Follow us on twitter

#9 ejectcore

    PrestaShop Addict

  • 08 Apr 2008
  • Members
  • PipPipPip
  • 827 posts
  • Location:UK

Posted 09 May 2008 - 05:55 PM

I am currently looking at a 3 column layout for one of my own projects & will try to update zip when complete  ::)
Filter Search 2.1 Enterprise Edition Now Available

Available Soon
Filter Search 2.1 Lite Edition

Follow us on twitter

#10 ejectcore

    PrestaShop Addict

  • 08 Apr 2008
  • Members
  • PipPipPip
  • 827 posts
  • Location:UK

Posted 09 May 2008 - 07:11 PM

Frontpage Categories Module V0.2
3 Column Front Page Category layout  8)
(Make sure you have the category size in the admin set to the same size as your images)

here's the css you need to add to global.css within your themes directory

#homeCatWrapper {
 margin-left: 6px; /* You may not need this unless you want to try to center categories */
}
#homeCat {
 float: left;
 width: 124px; 
}
#homeCat h5 {
 text-align: center; 
}

Attached File(s)


Filter Search 2.1 Enterprise Edition Now Available

Available Soon
Filter Search 2.1 Lite Edition

Follow us on twitter

#11 ejectcore

    PrestaShop Addict

  • 08 Apr 2008
  • Members
  • PipPipPip
  • 827 posts
  • Location:UK

Posted 09 May 2008 - 09:34 PM

Quote

Quick note: Make sure categories are enabled on the left column for the frontpage categories to work.
Question for the Prestashop Team how do I get this module to work in any position, it seems to only work when categories are displayed on the left column  ???


I missed out the obvious  :-[
allow for both hooks in header & footer

header.php
<?php
require_once(dirname(__FILE__).'/init.php');

/* CSS */
$css_files[_THEME_CSS_DIR_.'global.css'] = 'all';

/* Hooks are volontary out the initialize array (need those variables already assigned) */
$smarty->assign(array(
	'HOOK_HEADER' => Module::hookExec('header'),
	'HOOK_LEFT_COLUMN' => Module::hookExec('leftColumn'),	
	'HOOK_RIGHT_COLUMN' => Module::hookExec('rightColumn'),
	'HOOK_TOP' => Module::hookExec('top'),
));

if(isset($css_files) AND !empty($css_files)) $smarty->assign('css_files', $css_files);
if(isset($js_files) AND !empty($js_files)) $smarty->assign('js_files', $js_files);

/* Display a maintenance page if shop is closed */
if (isset($maintenance))
{
	header('HTTP/1.1 503 temporarily overloaded');
	$smarty->display(_PS_THEME_DIR_.'maintenance.tpl');
	exit;
}

$smarty->display(_PS_THEME_DIR_.'header.tpl');

?>


footer.php
<?php

if (isset($smarty))
{
	$smarty->assign(array(
     	'HOOK_RIGHT_COLUMN' => Module::hookExec('rightColumn'),	
		'HOOK_LEFT_COLUMN' => Module::hookExec('leftColumn'),
		'HOOK_FOOTER' => Module::hookExec('footer')));
	$smarty->display(_PS_THEME_DIR_.'footer.tpl');
}

?>

Filter Search 2.1 Enterprise Edition Now Available

Available Soon
Filter Search 2.1 Lite Edition

Follow us on twitter

#12 negoce

    PrestaShop Apprentice

  • 16 Feb 2008
  • Members
  • PipPip
  • 264 posts

Posted 09 May 2008 - 10:42 PM

Hi,

I like this contribution,

I try in RC3 stable...

Buy
------
Merci Presta et ses amis :cheese:
------

Negoce...

#13 RC3

    PrestaShop Newbie

  • 06 May 2008
  • Members
  • Pip
  • 12 posts

Posted 09 May 2008 - 11:29 PM

OK on RC3: http://www.asie-shop....com/boutique/ 

#14 negoce

    PrestaShop Apprentice

  • 16 Feb 2008
  • Members
  • PipPip
  • 264 posts

Posted 09 May 2008 - 11:35 PM

Hi,

thanks  ;)

how to creating on home categories on 3 or 4 columns ?

buy...
------
Merci Presta et ses amis :cheese:
------

Negoce...

#15 ejectcore

    PrestaShop Addict

  • 08 Apr 2008
  • Members
  • PipPipPip
  • 827 posts
  • Location:UK

Posted 09 May 2008 - 11:48 PM

Just use the css provided in the post above & download the latest zip  ;)
if not provide web link & I have a quick look  :)
Filter Search 2.1 Enterprise Edition Now Available

Available Soon
Filter Search 2.1 Lite Edition

Follow us on twitter

#16 negoce

    PrestaShop Apprentice

  • 16 Feb 2008
  • Members
  • PipPip
  • 264 posts

Posted 10 May 2008 - 12:05 AM

Hi,

Thanks & good night from France  :o

buy
------
Merci Presta et ses amis :cheese:
------

Negoce...

#17 ejectcore

    PrestaShop Addict

  • 08 Apr 2008
  • Members
  • PipPipPip
  • 827 posts
  • Location:UK

Posted 10 May 2008 - 12:11 AM

au revoir  ;D
Filter Search 2.1 Enterprise Edition Now Available

Available Soon
Filter Search 2.1 Lite Edition

Follow us on twitter

#18 Project 14

    PrestaShop Newbie

  • 11 Jul 2008
  • Members
  • Pip
  • 23 posts

Posted 26 July 2008 - 07:03 PM

Hi,
How can I get the category description to show in the {foreach} loop with this module? I've tried all the combinations of $category.desc / .description / .description_short - nothing seems to pull out the information - I just get a blank space.

Thanks,

#19 Project 14

    PrestaShop Newbie

  • 11 Jul 2008
  • Members
  • Pip
  • 23 posts

Posted 30 July 2008 - 09:46 PM

Any help on this - it must be a very simple answer...

#20 ejectcore

    PrestaShop Addict

  • 08 Apr 2008
  • Members
  • PipPipPip
  • 827 posts
  • Location:UK

Posted 30 July 2008 - 11:38 PM

Please post you code & I will see if I can help
I have plans to update this module but have a few more requests before going back to this :roll:
Filter Search 2.1 Enterprise Edition Now Available

Available Soon
Filter Search 2.1 Lite Edition

Follow us on twitter





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users