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

Edit Lists?

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 03-24-2015, 04:46 PM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Edit Lists?

I'm pretty sure I asked this before.. but.

I found this.
<ul class="account-links cf " IF="isAccountLinksVisible()">
<list name="layout.header.bar.links.newby" />
</ul>

How do I edit that list. I'd like view cart and checkout added.
__________________
xcart 5.1.2
Reply With Quote
  #2  
Old 03-24-2015, 06:25 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Edit Lists?

You assign things to the list, and take them away.
Templates can assign themselves to lists, and so can PHP classes.

Here is a class adding itself to a list:
* @ListChild (list="center", zone="customer")

And a template:
* @ListChild (list="capost_create_return.form.columns", weight="15")

In both cases you will see these declarations in the commented out section at the top of the file. I prefer to add templates/classes to lists by decorating the class or overriding the original template.

You can also do a lot of heavy lifting right in your main.php file.

To add a class or a template to a list, you wrap the call to the addClassToList() method in a function called runBuildCacheHandler() like this:
Code:
public static function runBuildCacheHandler() { parent::runBuildCacheHandler(); \XLite\Core\Layout::getInstance()->addClassToList( 'XLite\Module\CDev\Bestsellers\View\Bestsellers', 'sidebar.second', array( 'zone' => \XLite\Model\ViewList::INTERFACE_CUSTOMER, 'weight' => 100, ) ); \XLite\Core\Layout::getInstance()->addTemplateToList( 'modules/CDev/XMLSitemap/menu.tpl', 'sidebar.second', array( 'zone' => \XLite\Model\ViewList::INTERFACE_CUSTOMER, 'weight' => 100, ) ); }

You can remove a class from a list, and remove a template from a list in your main.php like this:
Code:
/** * Decorator run this method at the end of cache rebuild * * @return void */ public static function runBuildCacheHandler() { parent::runBuildCacheHandler(); \XLite\Core\Layout::getInstance()->removeClassFromList( 'XLite\View\LanguageSelector\Customer', 'layout.header.bar.links.newby', \XLite\Model\ViewList::INTERFACE_CUSTOMER ); \XLite\Core\Layout::getInstance()->removeTemplateFromLists( 'layout/main.location.tpl' ); }

You can move classes in lists:
Code:
protected static function moveClassesInLists() { return array( 'XLite\View\LanguageSelector\Customer' => array( array('layout.header.bar.links.logged', 'customer'), array('layout.header.magnifico.top.bar', 50, 'customer'), ), ); }

Move templates in lists:
Code:
protected static function moveTemplatesInLists() { $templates_list = array(); $templates_list = array( 'layout/header.bar.search.tpl' => array( array('layout.header.bar', 'customer'), array('layout.header.bar', 30, 'customer'), ), 'layout/header.right.tpl' => array( array('layout.header', 'customer'), array('layout.header', 350, 'customer'), ), ); return $templates_list; }

I took most of these examples from my Magnifico template, but you can see where I originally learned them in XLite\Core\Layout.php
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote

The following user thanks totaltec for this useful post:
qualiteam (03-26-2015)
  #3  
Old 03-25-2015, 07:39 AM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Re: Edit Lists?

seems a bit heavy handed to add a couple of links to a template. why is it done like this?
__________________
xcart 5.1.2
Reply With Quote
  #4  
Old 03-25-2015, 10:25 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Edit Lists?

Quote:
Originally Posted by ARW VISIONS
seems a bit heavy handed to add a couple of links to a template. why is it done like this?

This lets you have complete control! Modules can assign whatever they want to lists, create lists, take things away etc.

I may have over-complicated my answer, I just wanted to arm you with all the info.

If you want to just add a couple links, you can either create a new template with your links, and assign that template to the list using the very first method I described * @ListChild (list="capost_create_return.form.columns", weight="15")

Or you can ovverride a template that is already added using your custom skin, and add the links there.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote

The following user thanks totaltec for this useful post:
qualiteam (03-26-2015)
  #5  
Old 03-30-2015, 10:14 AM
  zychen's Avatar 
zychen zychen is offline
 

Advanced Member
  
Join Date: Jul 2007
Posts: 48
 

Default Re: Edit Lists?

Hey Mike,

If you had a little time, could you confirm that removeTemplateFromLists is working in 5.2.x please?
My templates have started to mess up since my upgrade, have you faced any similar issues with the upgrade recently?

-Niboon
__________________
X-Cart 5.1.10
X-Cart Next 5.2.1 Beta
Reply With Quote
  #6  
Old 03-30-2015, 04:49 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Edit Lists?

Niboon,
I just attempted to upgrade a test site to 5.2.X for the first time, and I am having some major issues. So I cannot confirm this yet. I have not recommended any of my clients upgrade to 5.2 yet, because I can't seem to get it to go smoothly on any of my test environments.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote

The following user thanks totaltec for this useful post:
zychen (03-31-2015)
  #7  
Old 03-31-2015, 08:01 AM
  zychen's Avatar 
zychen zychen is offline
 

Advanced Member
  
Join Date: Jul 2007
Posts: 48
 

Default Re: Edit Lists?

I have found out what changed from version 5.1.x. for RemoveTemplateFromLists() in 5.2.x

Code:
RemoveTemplateFromLists('items_list\product\parts\list.button-add2cart.tpl')
does not work but
Code:
RemoveTemplateFromLists('items_list/product/parts/list.button-add2cart.tpl')
works.

It seems that backslash has stopped working and you HAVE to use forward slashes only.
__________________
X-Cart 5.1.10
X-Cart Next 5.2.1 Beta
Reply With Quote

The following 2 users thank zychen for this useful post:
qualiteam (04-01-2015), totaltec (03-31-2015)
  #8  
Old 04-01-2015, 01:34 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: Edit Lists?

I believe backslashes never worked on linux servers, only Windows understands that "\" is the same as "/" in file paths.
__________________
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

The following 2 users thank qualiteam for this useful post:
totaltec (04-01-2015), zychen (04-01-2015)
  #9  
Old 04-01-2015, 03:51 AM
  zychen's Avatar 
zychen zychen is offline
 

Advanced Member
  
Join Date: Jul 2007
Posts: 48
 

Default Re: Edit Lists?

Yes, I should mention that I've only used Windows for X-Cart.
__________________
X-Cart 5.1.10
X-Cart Next 5.2.1 Beta
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



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:29 PM.

   

 
X-Cart forums © 2001-2020