Zend Layout in ZF2 - layout

How can we set default layout in zf2 if the layout folder is out side the module directory

You can set the layout anywhere you want it doesn't have to be in the modules directory.
just set it inside your modules config
'view_manager' => array(
'display_not_found_reason' => true,
'display_exceptions' => true,
'doctype' => 'HTML5',
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => array(
'layout/layout' => '/anypath/you/want/view/layout/layout.phtml',
),
'template_path_stack' => array(
'/anypath/you/want/view',
),
),

As per the question posted the answer by #Andrew is correct .
When i notice the working of layout in zf2 i came to certain conclusion
Able to set the layout folder anyway in application environment
Only one layout is taken for all the modules , the layout taken is from the last module mentioned in application.config.php
For example
'modules' => array(
'Album',
'Testlist',
'Customer',
'Application',
'User',
),
Then the user layout will be taken .
if we have only one layout in the application this will be fine
To switching between layouts in the module came across
http://www.webtrafficexchange.com/zf2-configure-layout-each-module-edpmodulelayouts
which seems to be useful

The default layout is layout/layout configured in the view manager.

Related

WPBakery multiple WYSIWYG editors

so I am building fairly complex WP site based on WPBakery editor with tons of custom components.
I just found out that some of them need to have multiple textarea_html (WYSIWYG) fields and judging by documentation only one of those fields is allowed per component:
Text area with default WordPress WYSIWYG Editor. Important: only one html textarea is permitted per shortcode and it should have “content” as a param_name
They are defined like this:
array(
'type' => 'textarea_html',
'heading' => __( 'This is WYSIWYG editor', 'text-domain' ),
'param_name' => 'content',
'value' => __( '', 'text-domain' )
),
Adding more with the same type (textarea_html) just converts them (of course, per documentation) to basic textarea field like this:
array(
'type' => 'textarea',
'heading' => __( 'This is basic textarea block', 'text-domain' ),
'param_name' => 'someparamname',
'value' => __( '', 'text-domain' )
),
Any ideas how this could be done differently? Thought about using ACF but didnt had much luck there...

Show some navigation pages just in breadcrumbs not in top menu in zf2

I have a navigation and use it for breadcrumbs. I want to use it for top menu too , but I don't want to show my products in top menu.
How Can I achieve that ?
Add a custom attribute while defining the array in the module.config.php -
Eg:
array(
'label' => 'Product List',
'route' => 'product',
'action' => 'index',
'resource' => 'Product\Controller\Product:index',
'top_menu' => '0',
),
For the rest of the arrays set the top_menu attribute to 1.
In the partial file of top-menu, check -
<?php foreach ($this->container as $page) {
[...]
if($page->get('top_menu') == '1') {
//Code to display the menu.
}
[...]
} ?>
I hope it gives some idea.

Apply a module layout to zfcuser

i'm working on zf2 and try to use 2 differents layouts. 1 layout for a public module and another one (private layout") for all the others. Its works pretty well but my zfcuser module in the public module use the other layout :/
i tried this :
'template_map' => array(
'zfc-user/user/login' => __DIR__ . '/../view/layout/blank.phtml', // blank is my public layout
),
Instead of get the form in my layout, i get my form in the public layout AND in the "private" layout ...
Does someone can help me ?
The code evan provides here http://blog.evan.pro/module-specific-layouts-in-zend-framework-2 will do what you need with one minor change, replace __NAMESPACE__ with 'ZfcUser' so that you're listening for ZfcUser controller actions
public function init(ModuleManager $moduleManager)
{
$sharedEvents = $moduleManager->getEventManager()->getSharedManager();
$sharedEvents->attach('ZfcUser', 'dispatch', function($e) {
// This event will only be fired when an ActionController under the ZfcUser namespace is dispatched.
$controller = $e->getTarget();
$controller->layout('layout/alternativelayout');
}, 100);
}
Added to composer.json
"evandotpro/edp-module-layouts": "1.0"
Created /module/Application/view/layout/blank.phtml
<?php echo $this->content;
Added this to /config/autoload/global.php
return array(
'module_layouts' => array(
'ZfcUser' => 'layout/blank'
));
Finally to /module/Application/config/module.config.php
'view_manager' => array(
'template_map' => array(
//add this line
'layout/blank' => __DIR__ . '/../view/layout/blank.phtml',

Drupal 6- 404 is not showing for menu item URL pattern implemented using hook_menu

I have a hook menu
$items['mypage'] = array(
'title' => t('My Page title'),
'description' => '',
'type' => MENU_CALLBACK,
'page callback'=> 'my_home_page',
'access arguments' => array('access content'),
);
Now when I access a page which is not existing like "mypage/blahblah" it will show my home page(ie http://www.mydomain.com/mypage/blahblah is rendering content of http://www.mydomain.com/mypage). Instead of this I need to show a 404 page.
Can anybody give comment on this ?
You can try to paste the following code in your page call back function "my_home_page"
if ('' != arg(1)){
drupal_not_found();
}
Thanks
Rahul

hook_menu Title

I'm having some trouble with the titles of my pages.
English Settings Page :
$items['mymodule/admin'] = array(
'title' => 'Administrate',
'page callback' => 'mymodule_admin_home',
'access arguments' => array('access content'),
'type' => MENU_NORMAL_ITEM,
// ...
);
$items['mymodule/admin/settings/english'] = array(
'title' => 'English Settings',
'page callback' => 'drupal_get_form',
'page arguments' => 'mymodule_makeEnglishSettingsForm',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
The title I set for my page in my hook_menu module doesn't stick, instead, it sets the title to it's parent-most item. I know that I can use drupal_set_title($my-new-title) to fix it. But why is this misbehaving? What did I do wrong?
ITs problem with the cache, either you can clear the cache by navigating to admin/settings/performance or use cache_clear method.
Try clearing the menu cache after making your changes:
cache_clear_all('*', 'cache_menu', TRUE);
Or, if you have the Admin Menu module installed, go to /admin_menu/flush-cache/menu

Resources