Pulling a variable from the database in 5.6.3

Permalink
Hi I am having an issue, I used to be able to pull a variable (excuse my terminology i'm not an expert) from the database in the view.php of a block just using $var where var is the name of the field, i.e. in autonav i could use $orderBy to get the value alpha_asc or similar.

However i have been working on a couple of new C5 sites and can't get this to work, i've tried two different servers, am I going mad? did I not used to be able to do this?

Please help!

Thanks in advance

BHWW
 
BHWW replied on at Permalink Reply
BHWW
Ok, so the issue is actually that I can pull the values if i use the block directly, however if I use the $bt = BlockType::getByHandle(''); method in a page template, it fails to get all the values... any ideas? thanks
BHWW replied on at Permalink Reply
BHWW
Hi OK, for anyone looking for this in the future, the issue was with some blocks like the search block there are attributes set to show, however in some this isn't needed I guess so they aren't set.

What i had to do is look for these snippets of code and add the attributes I needed in the controller.

public $rssTitle;
public $truncateChars;


function view() {
   $this->set('rssTitle', $this->rssTitle);
   $this->set('truncateChars', $this->truncateChars);
}


Hope this helps someone.