Post by mortal » Sat Feb 23, 2019 11:20 pm

Hello. im trying to set some logic in response.php. but it wil not accept the regular config get function.

how do i add this function to the response.php file ?
example

(Plase remember that it is just an example below, and it would not work)

Code: Select all

if($this->config->get('some_status') == '1'){ 
echo 'hello';
 }

error :
Fatal error: Uncaught Error: Call to a member function get() on null

Newbie

Posts

Joined
Thu Mar 08, 2018 4:05 pm

Post by OSWorX » Sat Feb 23, 2019 11:59 pm

Because $this->config is not available in the response.php

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Administrator

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by mortal » Sun Feb 24, 2019 12:03 am

Thanks. but how can i use my configuration in response.php ?

Newbie

Posts

Joined
Thu Mar 08, 2018 4:05 pm

Post by OSWorX » Sun Feb 24, 2019 12:33 am

Just tested to see if it work, and yes.

Set and assign from where you need it:

Code: Select all

global $config;
$global = $this->config;
and in the response.php the other way:

Code: Select all

global $config;
$config->get( 'get_your_value' );
And to keeop it simple and able to update or installable whereever you want, do the change in the reponse via OCMod.

The easiest and simpliest way (while it could be also done in another).

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Administrator

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by mortal » Sun Feb 24, 2019 1:08 am

Thank you very much for helping out.
in my own quest to find a solution i tried this in framework.php

Code: Select all

$response->Conf($config->get('user'),$config->get('folder'));
and this in response.php

Code: Select all

	public function Conf($user,$folder) {

		$this->user = $user;
		$this->folder = $folder;

	}
Wich gives me the variables to work with via

Code: Select all

$this->user
$this->folder
And it also works.

my question to you is then. wich method is best for performance ?

i know about the OCmod system. and plan on releasing the mods im making. but i have applied for reseller. and not recieved a reply yet.

Newbie

Posts

Joined
Thu Mar 08, 2018 4:05 pm

Post by straightlight » Sun Feb 24, 2019 4:33 am

An alternative way would be in your system/framework.php file:

replace:

Code: Select all

$response = new Response();
with:

Code: Select all

$response = new Response($registry);
Then, in your system/library/response.php file,

find:

Code: Select all

private $output;
add below:

Code: Select all

private $registry;
Then, find:

Code: Select all

/**
	 * Constructor
add above:

Code: Select all

public function __construct($registry) {
		$this->registry = (object)$registry;
	}
	
	public function __get($name) {
		return $this->registry->get($name);
	}
This way, you can manipulate almost pretty much everything from the Opencart Registry (where all the variables have been registered until that point in system/framework.php file).

Code: Select all

$this->config->get
If you wish to validate that before applying your statement:

Code: Select all

if ($this->config->has

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 4 guests