Jump to content

so confused....


s_ainley87

Recommended Posts

Hello I am currently working with str_replace and it cuasing me so much grief I a am so confused, I currently have this code,

 

// where do we get the email assets from
	$this->image_path = "http://www.thiswebsite/assets/";




	} 	

	public function sendVoucher()
	{
		//die("mail sent from mailer.php");
		// takes subject (from TUID in translation file) and file name location/prefix, name of method in this class that we use to translate
		return $this->loadContentSend("voucher","emails/voucher_generic","translateTemplateVoucher");

	}

	public function translateTemplateVoucher($template)
	{
		//die(print_r($this->inputs['offerdesc']));

		require_once $this->global["rootpath"] . 'application/views/helpers/translate_functions.php';
		$translated = str_replace("[header]", formatting($this->translation_data->_("header")),$template);
		$translated = str_replace("[iMAGEPATH]",$this->image_path,$translated);
		$translated = str_replace("[DOMAIN]",$this->inputs['domain'],$translated);
	$translated = str_replace("[ASSETNAME]",$this->inputs['asset'],$translated);
	$translated = str_replace("[OFFERNAME]",$this->inputs['offername'],$translated);
	$translated = str_replace("[OFFERSUB]",$this->inputs['offersub'],$translated);
	$translated = str_replace("[OFFERDESC]",$this->inputs['offerdesc'],$translated);
	$translated = str_replace("[OFFERTERMS]",$this->inputs['terms_and_conditions'],$translated);
	$translated = str_replace("[RESTAURANTNAME]",$this->inputs['rname'],$translated);
	$translated = str_replace("[restaurantname]",$this->inputs['rname'],$translated);
	$translated = str_replace("[trACKLINK]",$this->inputs['track'],$translated);
	$translated = str_replace("[validstart]",$this->inputs['vstart'],$translated);
	$translated = str_replace("[validend]",$this->inputs['vend'],$translated);
	$translated = str_replace("[NOT DISPLAYING]",$this->inputs['notdisplaying'],$translated);
	$translated = str_replace("[VID]",$this->inputs['vid'],$translated);
	$translated = str_replace("[bIRTHDAY AGE]",$this->inputs['birthday'],$translated);
	$translated = str_replace("[birthday age]",$this->inputs['birthday'],$translated);
		//die(print_r($this->data["track"));
		return $translated;

	}


 

what I want is to be able to replace the [iMAGEPATH] if a condition is met, say that the territory_id of a website is 5 or 7 or whatever can anyone help?

Link to comment
https://forums.phpfreaks.com/topic/117007-so-confused/
Share on other sites

You have more to the class than posted so cant actually see what it is doing. However it seems that the data is held in a array parameter $this->inputs so i'm not sure where you are getting confused. Would you not add your conditional clases before the string replace so:

 

if($valueContainingTertId == 5 || $valueContainingTertId == 7) {
	$translated = str_replace("[iMAGEPATH]", $this->inputs['arrayKeyOfImagePathReplacement'], $translated);
}

Link to comment
https://forums.phpfreaks.com/topic/117007-so-confused/#findComment-601792
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.