Override plugin templates
-
Hi.
We bought pro version of your plugin and we want to make some styling changes. Is it possible to override plugin templates in child’s theme ?
Override templates like this: /vikrentcar/site/views/carslist/tmpl/default.php
-
Hi,
Thanks for contacting us. As you may have noticed, VikRentCar is written according to the MVC pattern of PHP. The path to the PHP file you listed is the template file responsible of the generation of the output of the “Cars List” shortcode.
If you need to make changes to the default HTML/PHP structure, then an override is the best solution, because you will still be able to install future updates without losing any of your changes. Instead, if you only need to make CSS changes for the styling, then creating an override isn’t necessary. You can add your custom CSS code inside your Theme, or you can use the apposite tool in Vik Rent Car from the Configuration page.
Overrides cannot be made through children themes. That file default.php should be copied onto the following directory:
/wp-content/uploads/vikrentcar/overrides/site/carslist/default.php
All missing directories should be created, but please notice that the base path above (/wp-content/uploads/vikrentcar) may be different in your installation, as this is calculated by using your WordPress settings.
Also, just for your information, we have a technical documentation on our website that explains how to identify template files that support overrides, and how to actually create one, either for a widget or for a page generated through a Shortcode.
We hope this helps!
The VikWP Team
Thanks for the answer.
We can override all the templates in ‘site’ directory, but overriding modules doesn’t work.
We are using this documentation: https://vikwp.com/support/knowledge-base/vik-rent-car/customization-tips/pages-overrides
We want to override /wp-content/plugins/vikrentcar/modules/mod_vikrentcar_cars/tmpl/default.php
We created this path:
/wp-content/uploads/vikrentcar/overrides/modules/mod_vikrentcar_cars/default.phpBut it doesn’t work.
Follow up question. We can see in admin panel, that cars create/edit window has field ” custom page title”. How can we echo it in custom location ?
Rokas.
Hi Rokas,
The “modules” are actually the WordPress widgets declared by Vik Rent Car. Those override files should work as well, but please remember that widgets do require you to select the override file from the apposite parameter “Layout”.
Just like how some widgets allow you to choose the default ordering/sorting, or maybe the date format, there’s a dedicated parameter called “Layout” which will read all the override files compatible with the widget.
Regarding the other question: the answer would require an example of PHP code. The file you are currently overriding has got access to the “params” variable of each car, and that’s where the “custom page title” value is stored. If you read the original source code of that “View” (page) you should be able to detect the exact PHP code used.
Thanks, we have missed layout change to override modules.
We tried to look for custom page title “params”, but we can’t find it. We can see it for name, short info, cost, categories and etc. Maybe you can give more detail answer in what template we should look.
We usually don’t show examples of PHP code, but that variable is used in the page “cardetails”.
Please read the PHP code of the file that prepares the template file of that View, so the file view.html.php inside the view “cardetails” and look for the array-key “custptitle”.
You will see how we access that variable and how we use it. You are free to do the same on any other override file, but please notice that the page title is handled by the WordPress native functions, and so third party plugins may interfere with that hook.Thanks, we got everything now.
Lastly, I don’t want to create new topic, so I ask here. As far as I understand you can’t have additional search fields. For example search by car’s characteristics. Correct ?
Yes, that’s correct. Even if the form was displaying additional input fields, you would have no way to let the main controller parse those new request values, as overrides are only available for template files.
However, the characteristics are available for filters in the search results. If you look at the official demo website you will see that we enabled the apposite configuration setting. So this is probably a built-in feature, it’s just available in the search results step, after the client has entered the input (search) values.
Thanks for the answer. We have enabled characteristics filter.
Another question has arisen. We see that vikrentcar has login and register forms. Does it have my account page with form where user can edit his personal information like email and etc. ?
Hi,
Not really, that page is only displayed if you enable the configuration setting to “require the login”, meaning that the check-out is protected and reserved to registered and logged in users.
This configuration setting is turned off most of the times among our clients, because otherwise your clients must sign up or sign in in order to proceed with the rental order. This is not so good in terms of conversion, especially because your clients could access their rental orders without needing a login, it would be sufficient to use their order confirmation number to find it from the apposite “User Orders” page that you can create and publish through the apposite Shortcode.
This is up to you of course, and both the sign up and sign in functions are completely handled by WordPress. This means that by signing up for a new account, a new WordPress user will be created. However, our plugin does not provide functions to edit the billing or personal information, especially because your clients could be placing rental orders on behalf of someone else (i.e. travel agencies or partner companies).
Thanks for the answer.
Maybe you can answer this.
We can see that in the foreach loop, thumbnail image is called like this into the variable:
$imgpath = file_exists(VRC_ADMIN_PATH.DS.’resources’.DS.’vthumb_’.$getcar[‘img’]) ? VRC_ADMIN_URI.’resources/vthumb_’.$getcar[‘img’] : VRC_ADMIN_URI.’resources/’.$getcar[‘img’];
Can we get the last image of car’s all the extra images similar to thumb without much coding ?
Also is it possible to override lib.vikrentcar.php file via uploads directory ?
Hello,
You should talk to our programmers through our website for things related to code. I guess you could do that, but you need to be able to access the array of the extra images, parse it, and get the (count – 1) key of that array to fetch the last image.
Lastly, the file lib.vikrentcar.php is a core file, it is not a template file that supports overrides, I’m sorry.
Thanks for the answers. If we decide to go ahead with our ideas we will contact your programmers through your website.
Which template is storing this form: https://vikwp.com/demo/vikrentcar/search/?pickup=1647885600&return=1648670400 ?
Hi,
The name of that View is “vikrentcar”. It’s what the plugin generates through the Shortcode of type “Search Form”.
- The topic ‘Override plugin templates’ is closed to new replies.