Access to PrestaShop corporate website French English Change language
Hello, Guest |
| Register
Remember me Forgot password ?
Site Map Site Map Contact us Contact us
PrestaShop job
 
Forum  >  PrestaShop v1.0 - v1.1b3  >  Modules  >  Thread

Team members online:


Rémi Gaillard

1 of 3
1
Post Reply
New Topic
Frontpage Categories Module

offline
Posted: 09 May 2008 03:18 PM   [ Ignore ]
Moderator
RankRankRankRankRankRankRank
Avatar

Messages :

  • total: 784
  • last 7 days: 0
Joined: 2008-04-08

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  wink

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><br /><h4>{l s=&#039;categories&#039; mod=&#039;homecategories&#039;}</h4><br />    {if isset($categories) AND $categories}<br /><div>

to:

<br /><div id=&quot;featured-products_block_center&quot; class=&quot;block products_block&quot;><br /><h4>{l s=&#039;categories&#039; mod=&#039;homecategories&#039;}</h4><br />    {if isset($categories) AND $categories}<br /><div class=&quot;block_content&quot;><br />

Enjoy  smile 

File Attachments
homecategories.zip  (File Size: 2830KB - Downloads: 123)
 
offline
Posted: 09 May 2008 04:57 PM   [ Ignore ]   [ # 1 ]
Moderator
RankRankRankRankRankRankRank
Avatar

Messages :

  • total: 784
  • last 7 days: 0
Joined: 2008-04-08

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

<br /><?php<br /><br />class Homecategories extends Module<br />{<br />    private $_html = &#039;&#039;;<br />    private $_postErrors = array();<br /><br />    function __construct()<br />    {<br />        $this->name = &#039;homecategories&#039;;<br />        $this->tab = &#039;Home&#039;;<br />        $this->version = 0.1;<br /><br />        parent::__construct(); // The parent construct is required for translations<br /><br />        $this->page = basename(__FILE__, &#039;.php&#039;);<br />        $this->displayName = $this->l(&#039;Frontpage Categories&#039;);<br />        $this->description = $this->l(&#039;Displays categories in the middle of your homepage&#039;);<br />    }<br /><br />    function install()<br />    {<br />        if (!Configuration::updateValue(&#039;HOME_categories_NBR&#039;, 10) OR !parent::install() OR !$this->registerHook(&#039;home&#039;))<br />            return false;<br />        return true;<br />    }<br /><br />    public function getContent()<br />    {<br />        $output = &#039;<h2>&#039;.$this->displayName.&#039;</h2>&#039;;<br />        if (Tools::isSubmit(&#039;submitHomecategories&#039;))<br />        {<br />            $nbr = intval(Tools::getValue(&#039;nbr&#039;));<br />            if (!$nbr OR $nbr <= 0 OR !Validate::isInt($nbr))<br />                $errors[] = $this->l(&#039;Invalid number of categories&#039;);<br />            else<br />                Configuration::updateValue(&#039;HOME_categories_NBR&#039;, $nbr);<br />            if (isset($errors) AND sizeof($errors))<br />                $output .= $this->displayError(implode(&#039;<br />&#039;, $errors));<br />            else<br />                $output .= $this->displayConfirmation($this->l(&#039;Settings updated&#039;));<br />        }<br />        return $output.$this->displayForm();<br />    }<br /><br />    public function displayForm()<br />    {<br />        $output = &#039;<br />        <form action=&quot;&#039;.$_SERVER[&#039;REQUEST_URI&#039;].&#039;&quot; method=&quot;post&quot;><br />            <fieldset><legend><img src=&quot;&#039;.$this->_path.&#039;logo.gif&quot; alt=&quot;&quot; title=&quot;&quot; />&#039;.$this->l(&#039;Settings&#039;).&#039;</legend><br />                <label>&#039;.$this->l(&#039;Number of categories displayed&#039;).&#039;</label><br />                <div class=&quot;margin-form&quot;><br />                    <input type=&quot;text&quot; size=&quot;5&quot; name=&quot;nbr&quot; value=&quot;&#039;.Tools::getValue(&#039;nbr&#039;, Configuration::get(&#039;HOME_categories_NBR&#039;)).&#039;&quot; /><br />                    <p class=&quot;clear&quot;>&#039;.$this->l(&#039;The number of catgeories displayed on homepage (default: 10)&#039;).&#039;</p><br />                    <br />                </div><br />                <center><input type=&quot;submit&quot; name=&quot;submitHomecategories&quot; value=&quot;&#039;.$this->l(&#039;Save&#039;).&#039;&quot; class=&quot;button&quot; /></center><br />            </fieldset><br />        </form>&#039;;<br />        return $output;<br />    }<br /><br />    function hookHome($params)<br />    {<br />        global $smarty;<br />        $category = new Category(1);<br />        $nb = intval(Configuration::get(&#039;HOME_categories_NBR&#039;));<br />        <br />        $smarty->assign(array(<br />            &#039;category&#039; => $category,<br />            &#039;lang&#039; => Language::getIsoById(intval($params[&#039;cookie&#039;]->id_lang)),<br />        ));<br />        return $this->display(__FILE__, &#039;homecategories.tpl&#039;);<br />    }<br /><br />}<br /><br />

 
offline
Posted: 09 May 2008 07:34 PM   [ Ignore ]   [ # 2 ]
Senior Member
RankRankRankRankRank

Messages :

  • total: 132
  • last 7 days: 0
Joined: 2008-03-08

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

 
offline
Posted: 09 May 2008 07:48 PM   [ Ignore ]   [ # 3 ]
Moderator
RankRankRankRankRankRankRank
Avatar

Messages :

  • total: 784
  • last 7 days: 0
Joined: 2008-04-08

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

Image Attachments
frontpage_categories.gif
 
offline
Posted: 09 May 2008 07:50 PM   [ Ignore ]   [ # 4 ]
Senior Member
RankRankRankRankRank

Messages :

  • total: 132
  • last 7 days: 0
Joined: 2008-03-08

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

 
offline
Posted: 09 May 2008 08:38 PM   [ Ignore ]   [ # 5 ]
Moderator
RankRankRankRankRankRankRank
Avatar

Messages :

  • total: 784
  • last 7 days: 0
Joined: 2008-04-08

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?

 
offline
Posted: 09 May 2008 08:47 PM   [ Ignore ]   [ # 6 ]
Partner
RankRankRankRankRankRankRank
Avatar

Messages :

  • total: 537
  • last 7 days: 8
Joined: 2007-12-22

I've installed this module on a RC2 test shop, it works perfectly.  You can see result at http://www.asie-shopping.com/boutique/ 
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

 Signature 

asie-shopping88x31.gif
boutique de décoration asiatique

userbar.jpg
Communauté francophone de Prestashop

 
offline
Posted: 09 May 2008 08:53 PM   [ Ignore ]   [ # 7 ]
Moderator
RankRankRankRankRankRankRank
Avatar

Messages :

  • total: 784
  • last 7 days: 0
Joined: 2008-04-08

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  smile
<div id="featured-products_block_center" class="block products_block">

 
offline
Posted: 09 May 2008 08:55 PM   [ Ignore ]   [ # 8 ]
Moderator
RankRankRankRankRankRankRank
Avatar

Messages :

  • total: 784
  • last 7 days: 0
Joined: 2008-04-08

I am currently looking at a 3 column layout for one of my own projects & will try to update zip when complete  ::)

 
offline
Posted: 09 May 2008 10:11 PM   [ Ignore ]   [ # 9 ]
Moderator
RankRankRankRankRankRankRank
Avatar

Messages :

  • total: 784
  • last 7 days: 0
Joined: 2008-04-08

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 {<br /> margin-left: 6px; /* You may not need this unless you want to try to center categories */<br />}<br />#homeCat {<br /> float: left;<br /> width: 124px; <br />}<br />#homeCat h5 {<br /> text-align: center; <br />}

File Attachments
homecategories_v0.2.zip  (File Size: 2348KB - Downloads: 91)
 
offline
Posted: 10 May 2008 12:34 AM   [ Ignore ]   [ # 10 ]
Moderator
RankRankRankRankRankRankRank
Avatar

Messages :

  • total: 784
  • last 7 days: 0
Joined: 2008-04-08

[quote author=amwdesign link=topic=2079.msg8940#msg8940 date=1210337832]
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

<br /><?php<br />require_once(dirname(__FILE__).&#039;/init.php&#039;);<br /><br />/* CSS */<br />$css_files[_THEME_CSS_DIR_.&#039;global.css&#039;] = &#039;all&#039;;<br /><br />/* Hooks are volontary out the initialize array (need those variables already assigned) */<br />$smarty->assign(array(<br />    &#039;HOOK_HEADER&#039; => Module::hookExec(&#039;header&#039;),<br />    &#039;HOOK_LEFT_COLUMN&#039; => Module::hookExec(&#039;leftColumn&#039;),    <br />    &#039;HOOK_RIGHT_COLUMN&#039; => Module::hookExec(&#039;rightColumn&#039;),<br />    &#039;HOOK_TOP&#039; => Module::hookExec(&#039;top&#039;),<br />));<br /><br />if(isset($css_files) AND !empty($css_files)) $smarty->assign(&#039;css_files&#039;, $css_files);<br />if(isset($js_files) AND !empty($js_files)) $smarty->assign(&#039;js_files&#039;, $js_files);<br /><br />/* Display a maintenance page if shop is closed */<br />if (isset($maintenance))<br />{<br />    header(&#039;HTTP/1.1 503 temporarily overloaded&#039;);<br />    $smarty->display(_PS_THEME_DIR_.&#039;maintenance.tpl&#039;);<br />    exit;<br />}<br /><br />$smarty->display(_PS_THEME_DIR_.&#039;header.tpl&#039;);<br /><br />?><br />

footer.php

<br /><?php<br /><br />if (isset($smarty))<br />{<br />    $smarty->assign(array(<br />&nbsp; &nbsp;      &#039;HOOK_RIGHT_COLUMN&#039; => Module::hookExec(&#039;rightColumn&#039;),    <br />        &#039;HOOK_LEFT_COLUMN&#039; => Module::hookExec(&#039;leftColumn&#039;),<br />        &#039;HOOK_FOOTER&#039; => Module::hookExec(&#039;footer&#039;)));<br />    $smarty->display(_PS_THEME_DIR_.&#039;footer.tpl&#039;);<br />}<br /><br />?><br />

 
offline
Posted: 10 May 2008 01:42 AM   [ Ignore ]   [ # 11 ]
V.I.P.
RankRankRankRankRankRank
Avatar

Messages :

  • total: 289
  • last 7 days: 0
Joined: 2008-02-17

Hi,

I like this contribution,

I try in RC3 stable…

Buy

 Signature 

------
Merci Presta et ses amis cheese
------

Negoce…

 
offline
Posted: 10 May 2008 02:29 AM   [ Ignore ]   [ # 12 ]
Apprentice
RankRank

Messages :

  • total: 12
  • last 7 days: 0
Joined: 2008-05-06

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

 
offline
Posted: 10 May 2008 02:35 AM   [ Ignore ]   [ # 13 ]
V.I.P.
RankRankRankRankRankRank
Avatar

Messages :

  • total: 289
  • last 7 days: 0
Joined: 2008-02-17

Hi,

thanks  wink

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

buy…

 Signature 

------
Merci Presta et ses amis cheese
------

Negoce…

 
offline
Posted: 10 May 2008 02:48 AM   [ Ignore ]   [ # 14 ]
Moderator
RankRankRankRankRankRankRank
Avatar

Messages :

  • total: 784
  • last 7 days: 0
Joined: 2008-04-08

Just use the css provided in the post above & download the latest zip  wink
if not provide web link & I have a quick look  smile

 
offline
Posted: 10 May 2008 03:05 AM   [ Ignore ]   [ # 15 ]
V.I.P.
RankRankRankRankRankRank
Avatar

Messages :

  • total: 289
  • last 7 days: 0
Joined: 2008-02-17

Hi,

Thanks & good night from France  :o

buy

 Signature 

------
Merci Presta et ses amis cheese
------

Negoce…

 
 
1 of 3
1
Fast Reply
New Topic