Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Determine what kind of page has been loaded within a template.

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 10-06-2017, 07:10 AM
  zeel's Avatar 
zeel zeel is offline
 

Member
  
Join Date: Oct 2017
Location: Ohio
Posts: 14
 

Default Determine what kind of page has been loaded within a template.

So my design has a very large header image at the top to showcase products. For things like the home page, I just want to show more or less random product images. For categories, I want to display the category image, and for products, I want to display the product image.

But those things all need to be in the same location on the page, so they end up in the same template. The problem is, while I figured out how to show the images I wanted, I can't figure out how to pick which one to display based on the kind of page that has been loaded.

I would think I could do something with a condition like:

Code:
if this.isProduct() then ...

But I can't find any reference that tells me what conditions are available to check.
__________________
Version: 5.3.3.3
Reply With Quote
  #2  
Old 10-06-2017, 09:13 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: Determine what kind of page has been loaded within a template.

https://forum.x-cart.com/showthread.php?t=73877
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
qualiteam (10-15-2017)
  #3  
Old 10-06-2017, 09:42 AM
  zeel's Avatar 
zeel zeel is offline
 

Member
  
Join Date: Oct 2017
Location: Ohio
Posts: 14
 

Default Re: Determine what kind of page has been loaded within a template.

After some translation, I was able to get the effect I needed:

Code:
{% if this.getTarget() == "category" %} {# Content for categories #} {% elseif this.getTarget() == "product" %} {# Content for products #} {% endif %}

Looks like I can just compare with the names of any file in classes/XLite/Controller/Customer for all the various possible page types.
__________________
Version: 5.3.3.3
Reply With Quote

The following user thanks zeel for this useful post:
qualiteam (10-15-2017)
  #4  
Old 10-15-2017, 10:51 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Determine what kind of page has been loaded within a template.

Controller class names don't translate to target names directly, but the idea is correct.

Targets like "product_options" will translate to "ProductOptions" controller class name.

Also, classes/XLite/Controller/Customer is not the only place for controller classes. Modules may have their controllers too.
So, you should look into classes/XLite/Module/*/*/Controller/Customer directories too.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 11:51 PM.

   

 
X-Cart forums © 2001-2020