Password protect category pages customisation

  • Posts: 71
  • Thank you received: 3
  • Hikashop Business
10 years 10 months ago #101761

Hi all,

I have been posting in another thread regarding a customisation of Hikashop. Xavier of Hikashop suggested I come here for my answer.

Here's the thread so far:

But to summarise, here's what I'm after:

I am setting up a shop that will sell photos taken at sports events.

Some of the photos will be of children, so I want to protect these from the general public as much as possible.

At each event where photographs are taken a passkey will be published. This will enable registered users to the site to access the selection of photos from that event. I know this is not a super secure way of protecting the photos, but I think at least it will provide some security.

So when the user gets to the site they will first have to register - then they will be given a list of events. When they click on their specific event they will have to enter the published passkey before they see the photos from that event. This will be a category within Hikashop.

In the previous thread, Xavier from Hikashop, gave me the following advice:

I think that you have to use the custom fields on the table category to set a password by category.
Then edit the view which is listing the products, generally "product / listing_img_title" and in this view add a check for the password.


So I have added a custom field called "passkey".

He then told me to add the following code:
if(!empty($this->element->passkey) && $app->getUserState( HIKASHOP_COMPONENT.'.passkey') != $this->element->passkey){
	// Display only a form to enter the passkey
		// > when pressing submit, save the value in session, and reload the page.
		// To save in session, you can use: $app->setUserState( HIKASHOP_COMPONENT.'.passkey',JRequest::getVar('passkey',''));
}elseif(empty($this->element->passkey) || $app->getUserState( HIKASHOP_COMPONENT.'.passkey') == $this->element->passkey){
	// Display the the code
}
And he told me to add it here:

Add it in the view "product / listing" before:
if(($this->params->get('show_image') && !empty($this->element->file_path))|| ($this->params->get('show_description',!$this->module)&&!empty($this->element->category_description))){


I've done this, but got the following error:

"Fatal error: Call to a member function getUserState() on a non-object in mysite/templates/js_memo/html/com_hikashop/product/listing.php on line 117"


Xavier said:

That's probably because $app is not declared, you can use '$app = JFactory::getApplication();'


That's when he told me to post here, in the commercial jobs.

I am not a coder so I don't understand how to use the $app solution.

Can anybody help, please.

Regards

Duncan McFarlane


DunxMax

The more we learn the less we know.

Please Log in or Create an account to join the conversation.

  • Posts: 33
  • Thank you received: 0
10 years 5 months ago #127405

Hi Duncan.
I have the same needs, to protect categories and/or products with a password.
Did you find someone the solve the problem ?

Thank you.

Regards

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 3
  • Hikashop Business
10 years 5 months ago #127475

Hi Gazweb,

Contact Xavier at Hikashop, he helped me through it in the end in his spare time. Works fine.

Duncan


DunxMax

The more we learn the less we know.
The following user(s) said Thank You: glazweb

Please Log in or Create an account to join the conversation.

Time to create page: 0.072 seconds
Powered by Kunena Forum