VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: effettoMapet on July 12, 2023, 08:40:17 AM

Title: Custom field value without html formatting
Post by: effettoMapet on July 12, 2023, 08:40:17 AM
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.
Title: Re: Custom field value without html formatting
Post by: GJC Web Design on July 13, 2023, 14:20:56 PM
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
              
}