Author Topic: Calling a customized version of login.php  (Read 13156 times)

ClaudioRomeo

  • Jr. Member
  • **
  • Posts: 102
    • VirtueMart Matters
Calling a customized version of login.php
« on: June 01, 2017, 09:08:44 am »
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
Code: [Select]
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

  • Jr. Member
  • **
  • Posts: 422
Re: Calling a customized version of login.php
« Reply #1 on: June 01, 2017, 11:35:24 am »
In default.php find this:

Code: [Select]
echo shopFunctionsF::getLoginForm ($this->cart, FALSE,$uri);
And change to this:

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

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3230
  • VirtueMart Version: 3.8.4
Re: Calling a customized version of login.php
« Reply #2 on: June 01, 2017, 12:03:04 pm »
Why not do a sublayout override??

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

regards
A

Joomla 3.9.19
php 7.3

ClaudioRomeo

  • Jr. Member
  • **
  • Posts: 102
    • VirtueMart Matters
Re: Calling a customized version of login.php
« Reply #3 on: June 01, 2017, 12:31:47 pm »
@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

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3230
  • VirtueMart Version: 3.8.4
Re: Calling a customized version of login.php
« Reply #4 on: June 01, 2017, 13:31:17 pm »
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:

Quote
I inserted newlogin.php into the sublayouts folder

It should go here:-
{modified}

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

Joomla 3.9.19
php 7.3

Ghost

  • Jr. Member
  • **
  • Posts: 422
Re: Calling a customized version of login.php
« Reply #5 on: June 01, 2017, 14:02:26 pm »
It should be templates\yourtemplate\html\com_virtuemart\sublayouts\newlogin.php. Unless some old VM version is used.

ClaudioRomeo

  • Jr. Member
  • **
  • Posts: 102
    • VirtueMart Matters
Re: Calling a customized version of login.php
« Reply #6 on: June 01, 2017, 23:16:15 pm »
@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

  • Jr. Member
  • **
  • Posts: 205
    • sO couture
  • VirtueMart Version: 3.2.14
Re: Calling a customized version of login.php
« Reply #7 on: June 02, 2017, 15:18:11 pm »
let us know when u get it working, so you can document it for the rest of us ;)
Webmaster for my wife (link in my profile ;)
Extensions / plugins : POSForWebshops, TemplatecreatorCK ,MaximenuCK, and PageBuilderCK, VM BatchEdit Pro, VM CustomFilters Pro, Awocoupon Pro, slogin, supersaas,  among other things...
Joomla! 3.8.6//VM 3.2.14//PHP7.0.18 & mariadb 10.1.22 on Debian
big up to notepad++!!!!

ClaudioRomeo

  • Jr. Member
  • **
  • Posts: 102
    • VirtueMart Matters
Re: Calling a customized version of login.php
« Reply #8 on: June 06, 2017, 17:30:23 pm »
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

  • Jr. Member
  • **
  • Posts: 205
    • sO couture
  • VirtueMart Version: 3.2.14
Re: Calling a customized version of login.php
« Reply #9 on: June 06, 2017, 21:59:26 pm »
 8) you rock. Thanks.
onenoted for when i reach that part of my own customization
Webmaster for my wife (link in my profile ;)
Extensions / plugins : POSForWebshops, TemplatecreatorCK ,MaximenuCK, and PageBuilderCK, VM BatchEdit Pro, VM CustomFilters Pro, Awocoupon Pro, slogin, supersaas,  among other things...
Joomla! 3.8.6//VM 3.2.14//PHP7.0.18 & mariadb 10.1.22 on Debian
big up to notepad++!!!!

Ghost

  • Jr. Member
  • **
  • Posts: 422
Re: Calling a customized version of login.php
« Reply #10 on: June 07, 2017, 07:50:07 am »
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

  • Jr. Member
  • **
  • Posts: 102
    • VirtueMart Matters
Re: Calling a customized version of login.php
« Reply #11 on: June 07, 2017, 08:33:34 am »
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