Links en rechts lijnen

Status
Niet open voor verdere reacties.

Donamd

Gebruiker
Lid geworden
16 feb 2010
Berichten
25
Hoe kan ik het rechtse gedeelte van $text, namelijk $value[1] rechts lijnen en het linkse gedeelte $value[0] links lijnen.

Code:
$text = $value[0].$value[1];

Ik had gedacht om iets te doen met een div tussen te voegen en hier rechts te laten lijnen, maar dit lukt niet zoals ik het nu probeer.

Code:
$text = $value[0].echo'<div style="align:right;">'.$value[1].echo'</div>'

Iemand een idee ?
 
float:left, en float:right
En een echo in een $variabele heeft geen nut natuurlijk.
 
Ik ben niet zo ervaren met PHP.
Heb de code als volgt aangepast maar dit lukt nog niet.

Code:
$text = $valueWithPrice[0].'<div style="float:right;">'.$valueWithPrice[1].'</div>';

Hierdoor wordt de toevoeging <div ... als tekst op het scherm afgebeeld.
 
Dat lijkt me sterk. Vertel anders eens precies wat je doet.
 
Er wordt een lijstje (array) $selects gemaakt waaruit de gebruiker de gewenste keuze kan selecteren.

Code:
foreach ($options as $valuesWithPrice) {
	$valueWithPrice = explode('@', $valuesWithPrice);

	if ( isset ($valueWithPrice[1]) ) {
                
                          $text = $valueWithPrice[0].'<div style="float:right">'.$valueWithPrice[1].'</div>';

	}

$selects[] = array('value' =>$valueWithPrice[0], 'text' => $text );

}
 
Maar wat gebeurt er precies, en wat zie je precies?
 
Ik gok dat je ergens PHP in probeert te voeren, waar dit niet kan.
 
Hierbij vindt U de volledige code van het betreffende PHP bestand.

Code:
<?php
defined('_JEXEC') or die();
$product = $viewData[0];
$params = $viewData[1];
$options = explode(',', $params->custom_qvariant);
$class='';
$selects= array();
if (!class_exists('CurrencyDisplay')) require(VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php');
$currency = CurrencyDisplay::getInstance();

foreach ($options as $valuesWithPrice) {
	$valueWithPrice = explode('@', $valuesWithPrice);

	if ( isset ($valueWithPrice[1]) ) {
                
		$op = $valueWithPrice[1][0];
		$price = substr($valueWithPrice[1], 1) ;
		$variant = substr($valueWithPrice[1], 0, 1) ;

		if ($variant == "*") {
			$text = $valueWithPrice[0] ;
		} else {
			$text = $valueWithPrice[0].'<div style="float:right">'.$valueWithPrice[1].'</div>';
		}
	} else {
		$text = $valueWithPrice[0] ;
	}

       $text = str_replace(',', '@@@', $text); //temp replace the commas
	$selects[] = array('value' =>$valueWithPrice[0], 'text' => $text );

}

$html = JHTML::_('select.genericlist', $selects,'customProductData['.$product->virtuemart_product_id.']['.$params->virtuemart_custom_id.']['.$params->virtuemart_customfield_id .'][custom_qvariant]','class=customqvariant','value','text',$selects[0],false,true);
$html =   str_replace('@@@', ',', $html); //reinsert the commas

echo $html;

?>
 
Blijkbaar wordt HTML onschadelijk gemaakt. Je moet dit beter in de template afhandelen dan in je PHP-code.
 
Bedoel je met CSS ?
Maar dan moet ik toch een class of id hebben om naar te verwijzen van het linkse gedeelte en van het rechtse gedeelte van mijn keuze mogelijkheid ?
Nu heb ik dit toch niet.

Kan je eventueel een voorbeeld geven wat je hiermee bedoeld ?
 
Ik zie dat je Joomla gebruikt (vertel dat er voortaan ook bij). Daar wordt alle HTML met templates geregeld. Dus daar moet je de boel goed uitlijnen.
 
Is inderdaad Joomla dat ik gebruik.
Ben zeker geen expert in HTML, PHP of Css, maar al zoekende vind ik wel vaak een oplossing.
Kan alleen niet voorstellen hoe dit vanuit de template zou moeten gebeuren.
Als je een voorbeeldje hebt mag je hiervan altijd code doorsturen.
 
Ik heb geen ervaring met Joomla. Maar als je de relevante code hier kan posten die dit deel in de template regelt. Dan is het wel gemakkelijker om je te helpen.
 
Ik denk dat het volgende Php bestand er voor zorgt dat de custom velden getoond worden.

Code:
<?php
/**
 *
 * Show the product details page
 *
 * @package    VirtueMart
 * @subpackage
 * @author Max Milbers, Valerie Isaksen
 * @todo handle child products
 * @link http://www.virtuemart.net
 * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * VirtueMart is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * @version $Id: default_addtocart.php 7833 2014-04-09 15:04:59Z Milbo $
 */
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
$product = $viewData['product'];

if(isset($viewData['rowHeights'])){
	$rowHeights = $viewData['rowHeights'];
} else {
	$rowHeights['customfields'] = TRUE;
}

if(isset($viewData['position'])){
	$positions = $viewData['position'];
} else {
	$positions = 'addtocart';
}
if(!is_array($positions)) $positions = array($positions);

$addtoCartButton = '';

if(!VmConfig::get('use_as_catalog', 0)){
	if($product->addToCartButton){
		//$addtoCartButton = $product->addToCartButton;
             
	} else {
		$addtoCartButton = shopFunctionsF::getAddToCartButton ($product->orderable);
	}

}


?>
	<div class="addtocart-area">
		<form method="post" class="product js-recalculate" action="<?php echo JRoute::_ ('index.php?option=com_virtuemart',false); ?>">
			<div class="vm-customfields-wrap">
				<?php
				if(!empty($rowHeights['customfields'])) {
					foreach($positions as $pos){
						echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$product,'position'=>$pos));
					}
				} ?>
			</div>	
		
				<?php
				if (!VmConfig::get('use_as_catalog', 0)  ) {
					echo shopFunctionsF::renderVmSubLayout('addtocartbar',array('product'=>$product));
				} 
                                ?>

			<input type="hidden" name="option" value="com_virtuemart"/>
			<input type="hidden" name="view" value="cart"/>
			<input type="hidden" name="virtuemart_product_id[]" value="<?php echo $product->virtuemart_product_id ?>"/>
			<input type="hidden" name="pname" value="<?php echo $product->product_name ?>"/>
			<input type="hidden" name="pid" value="<?php echo $product->virtuemart_product_id ?>"/>
			<?php
			$itemId=vRequest::getInt('Itemid',false);
			if($itemId){
				echo '<input type="hidden" name="Itemid" value="'.$itemId.'"/>';
			} ?>
		</form>

	</div>

<?php // }
?>

Kan je hiermee meer mee ?
 
Zal morgen eens kijken.
 
Status
Niet open voor verdere reacties.
Steun Ons

Nieuwste berichten

Terug
Bovenaan Onderaan