Jump to content

Check if file exists (Product-list.tpl) Not working on 2nd page


Kaper

Recommended Posts

Hello guys, i need to add following code into product-list.tpl , which works, but only on the 1st page (With blocklayered  module enabled)

Both codes working only on the 1st page (pagination)

{if file_exists("video/{$product.reference}.mp4")}
								<CODE HERE>
							{/if}

I have also tried this:

{assign var="video_reference" value="video/{$product.reference}.mp4"}	
							{if file_exists($video_reference)}
								<CODE HERE>
							{/if}

If i am right, i need to enter this condition as variable in product.php, but i have no knowlege to do that, is there anybody who can tell me how? Thanks and i really appreciate any answer!

Have a nice day!

Link to comment
Share on other sites

My video files are stored in https://mysite.com/video/product-reference-number.mp4 . The video files are named the same as the product reference are.

I just need to create condition if the file name "../video/{$product.reference}.mp4" (With variable product reference) exists, then do something...
In my case: i need to show video icon when product have the video. (IT means, if the video file exists with name of the product reference)

So i just need to show VIDEO ICON on the product list, when the video file for the product exists. 

Hope you can now understand what i need :) Sorry for my eng.

 

Link to comment
Share on other sites

@Kaper

After research i have come in this conclusion that the way you are trying is not possible you need to create a hook and use that in product-list.tpl

 

after than handel the hook code to show your video icon

product-list.tpl

{hook h="displayProductVideo" product=$product}

and hook code

public function hookDisplayProductVideo($params){

return '<i class="icon-home"></i>';

}

 

This code show the icon, you need to handel the params to show

 

thank you

Link to comment
Share on other sites

Thanks, where i have to put the hook code?

public function hookDisplayProductVideo($params){

return '<i class="icon-home"></i>';

}

So instead:

return '<i class="icon-home"></i>';return '<i class="icon-home"></i>';

return '<i class="icon-home"></i>';

 

I have to put this?

return '{if file_exists("video/{$product.reference}.mp4")}
								<!-- my code to show icon here -->
							{/if}';

 

Link to comment
Share on other sites

 

 

This work when the block layer module is disable.

{hook h="displayProductVideo" reference=$product.reference}

 

public function hookDisplayProductVideo($params){



$reference =$params['reference'];

if(file_exists("video/".$reference.".mp4")){

return '<i class="icon-home"></i>';

}

else{

return '';

}

}

 

Now it is late night i am going to sleep :) if any other can help you to pass value in block layer then this will solve the issue.

Thank you

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