News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Calling a customized version of login.php

Started by ClaudioRomeo, June 01, 2017, 09:08:44 AM

Previous topic - Next topic

ClaudioRomeo

Now login.php is a sublayout instead of a view. OK.
I need a slightly customized version of it, let's name it newlogin.php, and it has to be called by the /views/cart/tmpl/default.php view.
But I can't point out how to call newlogin.php instead of login.php, since I don't find any instruction like renderVmSubLayout('sublayoutname'[...]).
Has someone a suggestion for me?

J 3.7.2
VM 3.2.2
PHP 7.1
I'm the author of the VirtueMart 3 Reference Guide
https://www.virtuemartmatters.com

Ghost

In default.php find this:

echo shopFunctionsF::getLoginForm ($this->cart, FALSE,$uri);

And change to this:

echo shopFunctionsF::getLoginForm ($this->cart, FALSE,$uri, 'newlogin');

AH

Why not do a sublayout override??

\templates\yourtemplate\html\com_virtuemart\sublayouts\login.php

Regards
A

Joomla 3.10.11
php 8.0

ClaudioRomeo

@Ghost

  • I inserted newlogin.php into the sublayouts folder
  • I modified the /views/cart/tmpl/default.php file as you suggested
It seems not working: the original login.php is called anyway.
Unfortunately I'm not so confident to PHP to try experiments...
Can you suggest me something different?

@AH
Sure, your way works well, thank you.
But I need a little deeper solution, since the newlogin.php sublayout ought to be called only by the /views/cart/tmpl/default.php file and not by other views.
I'm the author of the VirtueMart 3 Reference Guide
https://www.virtuemartmatters.com

AH

#4
You can still use a single override

look at the default login.php

It is passed settings that allow you to do something different if the source is from the cart

if (!isset( $this->from_cart )) $this->from_cart = FALSE;

<?php if (!$this->from_cart ) { ?>


If however you still want to do a new layout:

QuoteI inserted newlogin.php into the sublayouts folder

It should go here:-
{modified}

templates\yourtemplate\html\com_virtuemart\sublayouts\newlogin.php
Regards
A

Joomla 3.10.11
php 8.0

Ghost

It should be templates\yourtemplate\html\com_virtuemart\sublayouts\newlogin.php. Unless some old VM version is used.

ClaudioRomeo

@AH
Your suggestion is quite interesting.
I have to investigate the correct syntax to achieve what I need, since I still can't call newlogin.php instead of login.php

@ Gost
Thank you for the correct path for the sublayout.
I'm the author of the VirtueMart 3 Reference Guide
https://www.virtuemartmatters.com

aftertaf

let us know when u get it working, so you can document it for the rest of us ;)

ClaudioRomeo

TaDaaa!
At the end, we were successful!
Ladies and gentlemen, here is the procedure.

Part one: create a new login sublayout
First of all, you have to create a new sublayout for the login form and customize it.

  • Duplicate the /components/com_virtuemart/sublayouts/login.php sublayout
  • Modify it as needed
  • Save it as newlogin.php in the same folder (/components/com_virtuemart/sublayouts)

Part two: create a new cart view
You have to create a new view for the cart: this one has to call newlogin.php instead of login.php.

  • Duplicate the /components/com_virtuemart/views/cart/tmpl/default.php view
  • Locate le line echo shopFunctionsF::getLoginForm ($this->cart, FALSE,$uri);
  • Change it into echo shopFunctionsF::getLoginForm ($this->cart, FALSE,$uri, $layout = 'newlogin');
  • Save it as newdefault.php in the same folder (/components/com_virtuemart/views/cart/tmpl)

Part three: configure VirtueMart for using the new cart view
Now you have to tell VirtueMart to use the newdefault.php view instead of the default one

  • In the Admin Panel, go to the Configure -> Configure -> Templates page
  • From the Cart layout box, choose newdefault.php
  • Save

Note: this procedure is intended to keep the original files untouched and to be therefore able in any time to revert to the default settings with just one clic. If needed you can create more copies of the login.php sublayout and default.php view.

That's all!

Special thanks to my workmate Valentina Baratti, who made the dirty job
I'm the author of the VirtueMart 3 Reference Guide
https://www.virtuemartmatters.com

aftertaf

 8) you rock. Thanks.
onenoted for when i reach that part of my own customization

Ghost

This works but is overly complicated for what you're trying to accomplish. Just use overrides:

1. Create newlogin.php in templates/your_template/html/com_virtuemart/sublayouts/.
2. Copy default.php from components/com_virtuemart/views/cart/ to templates/your_template/html/com_virtuemart/cart/.
3. In newly copied default.php add sublayout parameter to getLoginForm: echo shopFunctionsF::getLoginForm ($this->cart, FALSE,$uri, $layout = 'newlogin');

Simpler faster way without cluttering VM folders with custom files.

ClaudioRomeo

Thank you, Ghost.
But in my opinion an override not always is the most comfortable way to achieve such a result.
Newest versions of VirtueMart let the administrator choose views and sublayouts to be used, directly from the admin panel. This is a real godsend. This method let the Administrator revert to another view in just one click. An override does not.
Moreover, if you are urged to deploy the modified files to many websites, it's much more easier to build an installation file (like the Joomla's ones) that inserts them into the canonical folders: inserting them into the template used folder it's not so simple.

A consideration: I'm absolutely sure that the best way is the way I'm used to. I'm familiar with it, so I work easily and quickly.
Therefore I'm also sure you are right when you say that the override is the best way. At the same time, I am right when I say that another view is the best way.
;) :)
I'm the author of the VirtueMart 3 Reference Guide
https://www.virtuemartmatters.com