| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Remove Template From Lists Question | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
Remove Template From Lists Question
Tony, Everyone,
Hi! I am seeking to better understand the removeTemplateFromLists function (or do we call that a method?) I am using it in my module's, and it works for most templates that I try to remove. But one template on the product page: skins/default/en/product/details/parts/attributes_modify/body.tpl will not remove when I use this function(method?). Here is my code: Code:
http://youtu.be/rXSKz2Y1qXc Please help me understand why this template cannot be removed from lists, and also what the right way to override this template with my module. I want to add a div container around the <ul>. Thanks!
__________________
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. |
|||||||||
#2
|
|||||||||
|
|||||||||
Re: Remove Template From Lists Question
More Info: The class that assigns this template is XLite\View\Product\AttributeValues
There is a function "getDefaultTemplate" contained in this class, which specifies the template directory to be used. I have created a class in my module: XLite\Module\Baby\RFQ\View\Product\AttributeValues with the followng code: Code:
I have also created the template "skins/default/en/modules/Baby/RFQ/product/details/parts/attributes_modify/body.tpl" This appears to be working, X-cart is now using my template. So this resolves the problem, but the question remains. Why does removeTemplateFromLists not work, and is this the correct way to overcome this issue?
__________________
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. |
|||||||||
#3
|
|||||||||
|
|||||||||
Re: Remove Template From Lists Question
Hi Mike!
First of all, I am happy to hear the problem is resolved. However, I would decorate the \XLite\View\Product\Details\Customer\AttributeValu es class instead of \XLite\View\Product\AttributeValues The reason, why you could not achieve the needed result by removing template is because that template was not assigned into any view list. You can see it if you check the xc_view_lists table in the database. Instead, the viewer class was assigned to the 'product.details.page.info' view list and this class is \XLite\View\Product\Details\Customer\AttributeValu es as you can see in the Webmaster Kit: http://awesomescreenshot.com/0bf38f7ged So, the proper way to work around it is to decorate the class as you did, but you also can remove it from view list as well: \XLite\Core\Layout::getInstance()->removeClassFromLists('\XLite\View\Product\Details \Customer\AttributeValues'); Please, let me know if it helps. Tony.
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! |
|||||||||
|
#4
|
|||||||||
|
|||||||||
Re: Remove Template From Lists Question
Tony,
Thanks! First, just so you know, I am building a module that allows a special attribute RFQ to be assigned to a product. I need to check and see if this attribute is assigned or not, and if so make changes to how the attributes are displayed. I have looked and see there is no class: Quote:
Correct? Quote:
Quote:
Code:
Code:
I tried decorating the class you suggested: \XLite\View\Product\Details\Customer\AttributesMod ify and using the same code as above but it did not work. Can you suggest what code I would use in my decorator class to properly override this default template and perform my boolean test? Once again, thanks. It's great to talk to you man!
__________________
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. |
|||||||||
#5
|
|||||||||
|
|||||||||
Re: Remove Template From Lists Question
Well I made a mistake! I had a typo in my class. I have now successfully used your suggestion, and decorated the class \XLite\View\Product\Details\Customer\AttributesMod ify using the same code as above just changing the namespace and the extended class.
So I tried your other suggestion in order to further my knowledge. In my Main.php I have: Code:
__________________
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. |
|||||||||
#6
|
|||||||||
|
|||||||||
Re: Remove Template From Lists Question
Aha! I believe I have discovered why this code:
Code:
You do not need the beginning slash in front of the class you want to remove. So the correct code that does work: Code:
Tony, you have helped me immensely. I now understand much more than I did before. Having you around to confirm what I am doing is great! Let me know if you see any error in my final solution, or how it could be done better. I am simply decorating the \XLite\View\Product\Details\Customer\AttributesMod ify class, and adding the reference to my template directory, rather than removing the class. I just wanted to try the other method to see that it works. My last question in this thread,(I think) is the correct terminology to refer to "removeClassFromLists". Is this called a function? Or a method? When do you refer to something as a method, and when as a function?
__________________
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. |
|||||||||
#7
|
|||||||||
|
|||||||||
Re: Remove Template From Lists Question
Hi Mike!
Yes, you are right about my mistake in class name and about your implementation of the code I am so happy to see that you are learning X-Cart 5 really well. Please, keep asking questions if there is a need to. I am happy to help you with it. By the way, add me on Skype. My Skype ID is in the signature of any my email. As for function/method terms, if you call a code only by its name like str_replace() or preg_match() than it is a function. If you call code by the name in relation to the object/class $this->getName(), myClass::someStaticMethod() than this is a method, not function.
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! Last edited by tony_sologubov : 08-01-2014 at 01:36 AM. |
|||||||||
|
|
|||
X-Cart forums © 2001-2020
|