Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CMS PHP BLOCK] Remove view massiv assignment #1058

Closed
nadar opened this issue Oct 28, 2016 · 1 comment
Closed

[CMS PHP BLOCK] Remove view massiv assignment #1058

nadar opened this issue Oct 28, 2016 · 1 comment
Assignees
Milestone

Comments

@nadar
Copy link
Member

nadar commented Oct 28, 2016

In order to not overload the view files of blocks and reduce ram usage the contents of block configs should be requested instead of massiv assigned to the view. This will also fixed the problem to make sure if variables exists with isset() method and allows to define default values if not existing.

Old:

<? if (isset($vars['title'])): ?>
<h1><?= $vars['title']; ?></h1>
<? else: ?>
<h1>Does not exist</h1>
<? endif, ?>

new:

<h1><?= $this->varValue('title', 'Does not exists'); ?></h1>

BC Breaking

The following variables will be removed in the view files by default:

  • $vars['foo'], use $this->varValue('foo') instead.
  • $cfgs['foo'], use $this->cfgValue('foo') instead.
  • $placeholders['foo'], use $this->placeholderValue('foo') instead.
  • $extras['foo'], use $this->extraValue('foo') instead.
@nadar nadar added this to the 1.0.0-rc2 milestone Oct 28, 2016
@nadar nadar self-assigned this Oct 28, 2016
@nadar nadar closed this as completed in 2a6fa92 Nov 1, 2016
@nadar
Copy link
Member Author

nadar commented Nov 1, 2016

In order to dirty fix your php block view, insert the following code at the top of your php view file:

// <!-- RC2 UPDATE FIX!
$vars = $this->context->getVarValues();
$cfgs = $this->context->getCfgValues();
$extras = $this->context->getExtraVarValues();
$placeholders = $this->context->getPlaceholderValues();
// -->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant