In the user's roles "site developer" is checked.
In the permission's page for "site developer", "developer" is checked
In my module I have the following:
$items['batch/delete'] = array(
'page callback' => 'batch_delete',
'access arguments' => array('developer'),
'access callback' => TRUE,
'type' => MENU_CALLBACK
);
They are getting an error in Chrome: This webpage has a redirect loop
It turns out I had 'batch/delete' defined somewhere else, so I changed it and now it works.
Related
I am using the Yii2 Menu widget. This is my menu
echo Menu::widget([
'items' => [
'label' => 'Products',
'url' => '/products' // Not working.
'items' => [
[
'label' => 'New Products',
'url' => '/new-products'
]
]
]
]);
But the URL /products doesn't work when the user click Products, then the menu must be open (it works) and also open the URL /products (it doesn't work).
When specifying the URLs for the menu items you have to specify them
in the form of controller/action not just as /controller even if
the default action is used.
This is written on the top as a Note in the class reference yii-widgets-menu in the very first example code under comments.
So change your url for the Products item to
'url' => '/products/index'
and also for the new-products
'url' => '/products/new-products'
Hope it helps.
Note: when you specify URLs like /controller/action it will add it to the baseUrl or domain name removing everything after that.
Like if you have a domain http://example.com and you are on the page http://example.com/contact-us.
It will replace everything after the domain name and add your specified http://example.com/controller/action and if the menu item URL is provided like controller/action then clicking it will append it to the existing URL http://example.com/contact-us/controller/action.
You can't really expect that clicking "product" item will open submenu and redirect to /products page at the same. It does not make any sense, since you will be redirected to different page before you will have a chance to click something in submenu. That's why clicking on "products" only shows submenu dropdown. But this link actually works - try use middle mouse button or disable javascript in your browser.
In your case you should probably define your menu as:
echo Menu::widget([
'items' => [
'label' => 'Products',
'url' => '/products'
'items' => [
[
'label' => 'All Products',
'url' => '/products'
],
[
'label' => 'New Products',
'url' => '/new-products'
],
]
]
]);
All navigation links should be in submenu.
I create small site with Yii2 basic, and I have problem, I search every times and not resolved this, I try rewrite with .htaccess file but not success.
My site have more category get from database example: house-building, car, job, computer, travel.....
I would like user click on category example: http://example.com/house-building => it access category/index?category=house-building
Current, my config/web.php as bellow.
'urlManager' => [
'class' => 'yii\web\UrlManager',
// Disable index.php
'showScriptName' => false,
// Disable r= routes
'enablePrettyUrl' => true,
#'suffix'=>'.html',
'rules' => array(
''=>'site/index',
'/login.html'=>'/users/login',
'/register.html'=>'/users/create',
### End custom url
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
],
Can you help me resolved this issues.
Thanks you.
Use this rule:
'<category:\w+>' => 'category/index'
I need to access the current user logged in (if any) in any part of the application. Special paths like /admin requires special permissions (roles).
This is the firewall configuration (just one firewall) protecting the entire application but not allowing anonymous users (because I need the current user even in homepage).
I got a redirect loop even requesting /. Any help?
'security.firewalls' => array(
'secured' => array(
'pattern' => '.*',
'anonymous' => false,
'form' => array(
'login_path' => '/login',
'check_path' => '/login_check',
'username_parameter' => 'login[username]',
'password_parameter' => 'login[password]',
),
'logout' => array('logout_path' => '/logout')
)
)
Access rules requires ROLE_ADMIN only for paths starting with /admin . The rest is anonymous:
'security.access_rules' => array(
array('^/admin', 'ROLE_ADMIN'),
array('^.*', 'IS_AUTHENTICATED_ANONYMOUSLY')
),
To allow acces via IS_AUTHENTICATED_ANONYMOUSLY have have to allow anonymous.
'security.firewalls' => array(
'secured' => array(
'pattern' => '/',
'anonymous' => true,
// other stuff
)
)
'security.access_rules' => array(
array('^/admin', 'ROLE_ADMIN'),
array('^/', 'IS_AUTHENTICATED_ANONYMOUSLY')
),
If the user is logged in you can access them in every page. IS_AUTHENTICATED_ANONYMOUSLY is only a role, which have unauthenticated users (anonymous).
I developing magneto module, In this module i want to make a ajax request in admin panel.I don't understand were to add script and controllers.please help me.
My requirement:
When change the select box(On change) i want add some field in the form.
Mycode:
/app/code/local/<Namespace>/<Module>/Block/Adminhtml/<Module>/Edit/Tab/Form.php
$fieldset->addField('type', 'select', array(
'label' => Mage::helper('<Module>')->__('Article Type'),
'name' => 'status',
'values' => array(
array(
'value' => '',
'label' => Mage::helper('<Module>')->__('Choose'),
),
array(
'value' => 1,
'label' => Mage::helper('<Module>')->__('Normal'),
),
array(
'value' => 2,
'label' => Mage::helper('<Module>')->__('video'),
),
),
'required' => true
));
I am creating fields using this.
How can i add another field on change.
Where should i add script
Where should i add controller
I created this module using this instructions
Let this field always be on the form. But make it invisible and show when you need it.
In the same template where the form is.
Place controller in your module. On stackoverflow you can find many questions about creating your own magento module and controller.
While I was learning kohana and making single article, i encountered this problem.
I wanted to get my url to look like article/post_id/slug(optional) so I made the route.
Route::set('article', '/<controller>/<article_id>(/<article_slug>(/<id1>(/<id2>(/<id3>))))', array('article_id' => '[0-9]', 'article_slug' => '[a-zA-Z0-9_]+'))
->defaults(array(
'controller' => 'article',
'action' => 'read',
));
I even tried without 3rd parameter for Route::set but anyway returns error shown in the picture.
Thanks. (:
Try without the leading /:
Route::set('article', '<controller>/<article_id>(/<article_slug>(/<id1>(/<id2>(/<id3>))))',
array(
'article_id' => '[0-9]',
'article_slug' => '[a-zA-Z0-9_]+')
)->defaults(
array(
'controller' => 'article',
'action' => 'read',
));