Jump to content

template an individual category?


FireMe

Recommended Posts

Hi guys, I am new to Prestashop

What I am trying to do is have a special theme/template for my category called "client"

The client category is a category that hold sub categories for each client, which is private for a specific user group.

So really I want the category to show a login form instead of just saying "there are no products in this category"

So the client can go to the client category. be ask to login to view there products with a login form, then they can go to there private category.

and I am just after some advice on the best way to do it really thanks in advance

Link to comment
Share on other sites

Is it necessary for these private categories to be visible on your site? You can use the customer groups in PrestaShop to only show public categories when not logged in and show private categories too when a customer group logs in. For example, go to Customers > Groups, create a customer group called "Private" (or whatever is appropriate). You can then go to the Catalog tab, edit each category and choose which customers groups have access to the category. If it is a public category, tick all the customer groups including "Default" so that everyone can see it. If it is a private category, tick only the customer group who should have access to the category and leave "Default" unticked.

Link to comment
Share on other sites

Hi Rocky

Thanks for the reply, I have actually already done what you have said, every one can view the client category, but only selected groups can view the sub categories.

What I want to do is add a login form to the client category, So that when you login it redirects you to the client area. So the client can then see there private category straight away. if you get what I mean?

Thanks in advance

FireMe

Link to comment
Share on other sites

I'm not sure what you mean, since the private categories should already appear when a customer logs in. Do you mean you want to redirect to the private category product listings page after logging in? If you want to do that, you'll need to modify authentication.php and change line 170 (in PrestaShop v1.3.1) from

Tools::redirect('my-account.php');



to:

if ($customer->isMemberOfGroup(2))
{
   $privateCategory = new Category(4, intval($cookie->id_lang));
   Tools::redirect($link->getCategoryLink($privateCategory));
}
else
   Tools::redirect('my-account.php');



Whenever a customer you've added to customer group 2 logs in, this code should redirect the customer to category 4. Change 4 to the ID of the private category you want to redirect to. If the customer isn't in group 2, they will be redirected to the "My Account".

Link to comment
Share on other sites

Hi Rocky

Thanks again for the reply, Sorry I don't seem to be explaining my self very well :-(

I have a category called "Clients" which is not a private category(every one can see it), with no products within it. But I have sub categories that are private for each client. you with me?

What I want to do is have a big login form on the Clients category where the products would normal be?

So basicly the page would look like this


Clients

Please login to view your client area below

Email :---------------------
Password :---------------------



Then it would redirect you back to the same page but loged in? so then the client could see there category straight away, and see there products.


Thanks in advance

hope this helps? :-)

Link to comment
Share on other sites

If think it is very difficult to do it the way you are suggesting, since you'd have to copy the authentication page into your category page, which will probably cause problems. You could put a link to the authentication page on the category page so that customers know they must log in or sign up to see the categories. For example, change line 58 of category.tpl from:


{if $smarty.get.id_category == 2}{l s='Please'} {l s='sign up or log in'} {l s='to access these categories.'}{else}{l s='There are no products in this category.'}{/if}



This will display "Please sign up or log in to access these categories." with a link to the authentication page on the category 2 product listings instead of "There are no products in this category.". Change 2 to the ID of your client category.

Link to comment
Share on other sites

Hi Rocky thanks for your help I have managed to get what I want. I have done the following.

copied authentication.php

changed line 169 from this

Tools::redirect('my-account.php');



to this

$privateCategory = new Category(13, intval($cookie->id_lang));
Tools::redirect($link->getCategoryLink($privateCategory));



and saved as authentication2.php

So that there is both authentication.php and authentication2.php

and in the category.tpl


{if $smarty.get.id_category == 13}{l s='Please'}
<form action="{$base_dir_ssl}authentication2.php" method="post" id="login_form" class="std">

{l s='Already registered ?'}


{l s='E-mail address'}
<input type="text" id="email" name="email" value="{if isset($smarty.post.email)}{$smarty.post.email|escape:'htmlall'|stripslashes}{/if}" class="account_input" /></span>



{l s='Password'}
<input type="password" id="passwd" name="passwd" value="{if isset($smarty.post.passwd)}{$smarty.post.passwd|escape:'htmlall'|stripslashes}{/if}" class="account_input" /></span>



               {if isset($back)}<input type="hidden" class="hidden" name="back" value="{$back|escape:'htmlall':'UTF-8'}" />{/if}
               <input type="submit" id="SubmitLogin" name="SubmitLogin" class="button" value="{l s='Log in'}" />


{l s='Forgot your password?'}

   </form>
{/if} 



which adds a login form and uses the authentication2.php, which redirects it back to the category

Is there anyway I can do an {if) statement, So if you are loged in the form will not be displayed?

Thanks in advance

Link to comment
Share on other sites

  • 1 year later...

Hi, to display a category diferently than the rest, the only way is to do it with a conditional inside the category.tpl, or their is a way to ser a diferent template for diferent categories using template naming convention, as in wordpress?

 

I am not finding any information on the template naming conventions....

 

Any info would be very welcome,

 

Thanks, Gioia

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