News:

Support the VirtueMart project and become a member

Main Menu

Custom field value without html formatting

Started by effettoMapet, July 12, 2023, 08:40:17 AM

Previous topic - Next topic

effettoMapet

Good morning,
Is it possible somehow to take ONLY its content of a custom field without all the html structure?

Let me explain my need:

In the product sheet I have to enter the url address of a friend site (for example google.com).
To do this I am using the 'text area' custom field, because it is the simplest of all for the user who has to load data on the product sheet, he absolutely must NOT be able to do graphic formatting or other things.

Inside html > com_virtuemart > productdetails > default.php
enter this string to invoke the custom field:
echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'box_wwwfriendly','class'=> 'box_wwwfriendly'));

Using this string obviously the entire html structure of the custom field appears to me, which I don't care about. I just need to be able to insert in a tag <a href="XXX"> the value entered in the custom field (for example www.googole.com)

Do you know how I can do it without having to install new modules and plugins?
Thanks for your interest.

GJC Web Design

you either need to make a copy of your template  customfields.php

templates\gjc_template\html\com_virtuemart\sublayouts\my_customfields.php

and call it by    echo shopFunctionsF::renderVmSubLayout('my_customfields',array('product'=>$this->product,'position'=>'box_wwwfriendly','class'=> 'box_wwwfriendly'));

then display what ever u want .. i.e. just the value

or in templates\gjc_template\html\com_virtuemart\sublayouts\customfields.php

make an else based on position - something like below .. not tested

e.g.


<?php if (!empty($product->customfieldsSorted[$position])) {
if($product->customfieldsSorted[$position][0]->layout_pos == 'box_wwwfriendly'){ ?>

<div class="box_wwwfriendly">
<?php
foreach ($product->customfieldsSorted[$position] as $field) {

if ( $field->is_hidden || empty($field->display) || $field->published 0) continue; 

echo $field->display;
}
}
?>

</div>
<?php }else{
                     
//continue the original code
              
}


GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation