view-helpers

Resolve view helper location from within the controller or form

时光怂恿深爱的人放手 提交于 2019-12-08 09:53:10
问题 I have a few view helpers that add JavaScript files when they're needed (for instance, so that only forms use CKEditor and such). My directory structure (simplified to include only the relevant files) is this: application --forms --Project AddIssue.php --modules --default --views --helpers JQueryUI.php Wysiwyg.php --project --controllers ProjectController.php --views --scripts --project version.phtml issueadd.phtml What I want to do: include CKEditor in the view project/project/issueadd

ZF2 register custom helper for navigation

橙三吉。 提交于 2019-12-08 02:29:44
问题 I am using Zend Navigation with ACL . My users can have multiple roles, which have no relation to each other, but Zend Navigation only accepts one role and checks the ACL with that role which is not good for me. How can I register a new Helper for the Navigation such that I can override the acceptAcl method. I tried to create and register a simple view helper but that didn't work class Menu extends \Zend\View\Helper\Navigation\Menu implements \Zend\ServiceManager\ServiceLocatorAwareInterface

ZF2 use database table model in view helper

廉价感情. 提交于 2019-12-07 23:54:30
问题 To show an database count in my layout.phtml I want to use the view helper to render ths count (set in an db field). How do I use my database model in a view helper? Helper: namespace Application\View\Helper; use Zend\View\Helper\AbstractHelper; class CountHelper extends AbstractHelper { protected $count; public function __invoke() { return $this->count(); } public function setTableCount($sm, $myCountTable) { $this->count = $sm->get($myCountTable)->getCount(); return $this->count; } } Module

TYPO3 ver. 7.6.2 - Condition ViewHelpers evaluated only once

試著忘記壹切 提交于 2019-12-07 11:13:05
问题 Problem: I wrote a conditional VH (extending AbstractConditionViewHelper ) and it works as usually, anyway I realized that in non-cached version it is evaluated only once. Initialy I thought that's my bug, but checked common <f:if> and the problem is identical :S In general when I visit my page for the first time, condition is evaluated and valid result is given, but when I'll refresh the page VH isn't called anymore (checked by setting breakpoint inside the VH) and VH is always treated as

Label is getting displayed below checkbox

对着背影说爱祢 提交于 2019-12-07 11:12:37
问题 <%= f.check_box :openid_enabled %> <%= f.label :openid_enabled, 'OpenID' %> Above code generate this HTML <input type="hidden" value="0" name="application[openid_enabled]"> <input type="checkbox" value="1" name="application[openid_enabled]" id="application_openid_enabled"> <label for="application_openid_enabled">OpenID</label> and the label is getting displayed like [x] OpenID instead of [x] OpenID Do I need to style it or rails helpers have some build in functionality? Added I am using

Zend Framework 2: formatting a date in a view

只谈情不闲聊 提交于 2019-12-06 15:13:40
问题 I'm new to Zend framework and have decided to try to build a simple app using ZF2. I have a date that is being pulled from the database where my table gateway extends the AbstractTableGateway, this is pulling my data correctly but i'd like to format my date using Zend_Date and not manipulate the string representation myself in my model / view. Does anybody have any ideas about how i do this? 回答1: Here is my custom datatime helper for reference: https://github.com/AlloVince/eva-engine/blob

ZF2 use database table model in view helper

孤人 提交于 2019-12-06 12:08:10
To show an database count in my layout.phtml I want to use the view helper to render ths count (set in an db field). How do I use my database model in a view helper? Helper: namespace Application\View\Helper; use Zend\View\Helper\AbstractHelper; class CountHelper extends AbstractHelper { protected $count; public function __invoke() { return $this->count(); } public function setTableCount($sm, $myCountTable) { $this->count = $sm->get($myCountTable)->getCount(); return $this->count; } } Module public function getViewHelperConfig() { return array( 'factories' => array( 'CountHelper' => function(

ZF2 - multiple nav menus using the navigation view helper

别来无恙 提交于 2019-12-06 07:31:47
问题 I am trying to use a main navigation in combination with a submenu for more specific navigating. In my layout I am calling the view helper like this: $this->navigation('main_navigation')->menu() and in my view I am calling it like this: $this->navigation('sub_navigation')->menu() The problem is that whenever I call the navigation() view helper a more than once , it just outputs the second one in both places. In other words, it's printing the subnav for both the main nav and the subnav menus.

ZF2 register custom helper for navigation

非 Y 不嫁゛ 提交于 2019-12-06 06:13:30
I am using Zend Navigation with ACL . My users can have multiple roles, which have no relation to each other, but Zend Navigation only accepts one role and checks the ACL with that role which is not good for me. How can I register a new Helper for the Navigation such that I can override the acceptAcl method. I tried to create and register a simple view helper but that didn't work class Menu extends \Zend\View\Helper\Navigation\Menu implements \Zend\ServiceManager\ServiceLocatorAwareInterface { protected function acceptAcl(AbstractPage $page) { if (!$acl = $this->getAcl()) { // no acl

Converting Rails 3 to Rails 2: helpers with blocks

一笑奈何 提交于 2019-12-06 04:46:05
问题 In Rails 3 I use the following helper in order to get a even-odd-coloured table: def bicolor_table(collection, classes = [], &block) string = "" even = 0 for item in collection string << content_tag(:tr, :class => (((even % 2 == 0) ? "even " : "odd ") + classes.join(" "))) do yield(item) end even = 1 - even end return string end And I use it in my views like this: <%= bicolor_table(services) do |service| %> <td><%= image_tag service.area.small_image %></td> <td><%= link_to service.title,