I'm trying to understand how spiffy-navigation works. I integrate the module, it's working very well. I have my navigation.
But the doc says :
Rbac specific options
role: required The role to use to determine if access is granted.
permission: required The permission to use to determine if access is
granted.
But, even if i did something like that, it still not working.
'containers' => array(
'default' => array(
array(
'options' => array(
'label' => 'profil',
'route' => 'profil',
'role' => 'members',
'permission' => 'member'
),
'pages' => array(
// ...
)
)
)
),
EDIT(May 27) :
This is in fact a try of this discussion :ZF2 Generate navigation using zfcrbac zfcUser and hierarchical role strategy
My Question is the same :
How to generate a dynamic navigation, for a user wich can only see links that is granted to access ?
For example when you write this :
<?php echo $this->navigation('navigation')->menu()->setUlClass('nav navbar-nav')?>
In our layout in ZF2 without zfcRbac we can specify getAcl(), setAcl(), getRole() and setRole(), gets and sets ACL (Zend\Permissions\Acl) but with zfcRbac this didn't work.
Spiffy Navigation need to be improved for doing that(it's the prototype of zf3 navigation). It's not the aim of ZfcRbac module.
if someone has a solution it would be nice.
Related
I am working in Sugarcrm 7.8 I am trying to create a relationship between contacts and my custom module example myorder but its not showing in type field when I select my custome module in `Related Module'.
I couldnt able to find any doc which explains such situation. How i can make a one-to-one relationship through studio when its not showingup. I really dont like to create through code as it breaks operations while we try to retrive report. If i work through studio its fine.
Any how i tried creating the follwing files to see if it shows any relationship.
src/custom/Extension/application/Ext/TableDictionary/contacts_myorder_1.php
src/custom/metadata/contacts_myorder_1MetaData.php
But it creates a new relationship via code.
Has anyone been able to achieve anything similar?
Community Question: https://community.sugarcrm.com/message/94195-one-to-many-relationship-type-is-not-showing-in-studio
After some deep research found that, In my custom module i should have explained the relationship between the modules.
After creating the follwoing file. I could able to see the relationships.
src/modules/mycustomodule/clients/base/layouts/subpanels/subpanels.php
src/modules/mycustomodule/vardefs.php
Content: subpanels.php
array (
'layout' => 'subpanel',
'label' => 'LBL_MYCUSTOMMODULE_SUBPANEL_CONTACTS',
'context' => array (
'link' => 'mycustommodule_contacts',
),
),
Content: vardefs.php
'mycustommodule_contacts' => array(
'name' => 'mycustommodule_contacts',
'type' => 'link',
'relationship' => 'contacts_mycustommodule',
'module' => 'Contacts',
'bean_name' => 'Contact',
'source' => 'non-db',
'vname' => 'LBL_MYCUSTOMMODULE_CONTACTS_LINK',
),
After Repair & Rebuild. It works as expected. Hope it helps someone.!
I have been tasked to explore the possibilities of creating dynamic urls.
What we try to achieve is serving a domain for the client.
eg. www.example.com/clients/john/
eg. www.example.com/clients/bill/
These urls are not fixed, but have to be made dynamically everytime a Client registers at our site. Our URL's are build of Controllers and Actions. Like www.example.com/controller/action.
How can this be achieved in the PHP Zend Framework 2?
Big thanks in advance!
All you need is the ZF2 Manual:
I suggest to use segment routes
You can define them like:
'client' => array(
'route' => '/clients/:username',
'constraints' => array(
'username' => '[a-zA-Z][a-zA-Z0-9-]+', //accepted value pattern
),
'defaults' => array( //which action to invoke
'controller' => 'Application\Controller\ClientController',
'action' => 'showclient',
),
));
Then you can create an url with url helper like:
$this->url('client', array('username' => 'John'));
And in your controller you will be able to get username param with:
$this->params()->fromRoute('username');
I'm trying to make a website using the Zend Framework 2, but I have a simple problem driving me crazy.
I'd like to make a simple about-us.html page with static content because there is no need to do anything else than display html.
There is no need to create a Controller / model etc...
Maybe you have to question why you're using ZF in the first place. If you just want to create a static internet page, do that without a PHP framework!
If you didn't ask your question well and you're actually just adding a static page to an existing ZF application, why not just using the existing IndexController, add an empty action and add your static content to the corresponding .phtml?
Alternatively you can look at PhlySimplePage, a ZF2 module for the purpose of adding simple static pages to a ZF app. It's written by Matthew Weier O'Phinney, the lead dev of ZF.
As the readme says, this module eliminates the need to create a controller and an action. So all you need to do is create a route and a view script.
I know this question might be old, but I was in trouble with that as well.
Here is what I did to create a generic router for my application, so I could just add as many actions as I need and have then created as phtml files in my view
on module.config.php
'application' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:action][/]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'Application\Controller\Index',
'action' => 'index',
),
),
),
So basically what it does is gets any action you might have in your application and use as a page... like any other controller
Instead of http://yoursite.com/application/test
you can do now http://yoursite.com/test
if you have your testAction set in your indexController file.
Hope I had helped future people looking for this information.
You have to create controller and view file.
suppose there is a about us menu with link
<a href="<?php $this->url('aboutus'array('action'=>'aboutus'));?>">
About Us
</a>
Just go to aboutus view file and write static html code.
Thanks
Alok
I've created a module, a basic copy of the the albums example given in the ZF2 documentation, however, with the new module, I am not able to access it at all - I'm always given a 404 error. I'm building this on the ZF2 skeleton.
I've got three modules loaded: Application, Frontend and Security.
Both Frontend and Security are duplicates of each other, however, I have thoroughly checked and there is no reference to old code (as I literally copied the module folder and renamed/rewrote references).
The module is also loaded in application.config.php.
Any ideas on what I'm missing?
Module Config:
return array(
'controllers' => array(
'invokables' => array(
'Security\Controller\Security' => 'Security\Controller\SecurityController',
),
),
'router' => array(
'routes' => array(
'security' => array(
'type' => 'segment',
'options' => array(
'route' => '/security[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Security\Controller\Security',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'security' => __DIR__ . '/../view',
),
),
);
I had the same problem while following the skeleton application tutorial (Getting started: A skeleton application). Whenever I would go to the album url in the browser (ZendSkeletonApplication/public/album in my case), I would get a 404 error page but no details on why I got the 404. It wasn't clear to me how I would be able determine why I was getting the 404 when I had double checked everything and was pretty sure I copied and configured the Album module properly. It turned out that I was missing a slash in my route (module.config.php). For example I had 'route' => 'album[/:action][/:id]' instead of 'route' => '/album[/:action][/:id]'.
I was only able to figure it out by intentionally causing errors by misspelling things like making the 'Album\Controller\Albums' instead of 'Album\Controller\Album'in the invokables value, this would cause a stack trace to display which then showed the ZF2 classes that where called on the request. I would continue to misspell, test, and then correct each part of the module.config.php until I was given a clue to what part of the configuration was causing the error.
I'm pretty sure this was not the best way to debug an application's configuration.
There is few things that need to be make sure is:-
You have to add your module in
application.config.php (which you are saying you done it.)
Security\Controller\Security has to be same in default too (which you already has)
One more thing is Your folder structure....
-
Just to doulbe check you have a /MODULE/src/MODULE/Controller/CONTROLLER_FILE_NAME.php
I hope that helps..
I know it is an old post. However another thing to make sure you have in the modules top directory (same directory as the Module.php file) is the "autoload_classmap.php"
file with "<?php return array();?>" inside of it.
A simple tip to know whether your rule has already added correctly to the routes or not, you may check the routes value in the config file inside any working module, as following:
$config = $this->serviceLocator->get('config');
var_dump($config);
Novice Zend Framework developer here trying to figure out a simple solution to a Zend Routing problem. I'm sure one of you pros can lend a hand.
I have a website (built in Zend Framework using Zend_Navigation) that contains 75% static HTML page content and a few controllers. Top level navigation is built in Zend_Navigation, looping through partials.
Because of my work I build a lot of sites along these lines (containing lots of static pages) so I want to get this right. I don't want to set up controllers and actions for each and every one of these static pages (there are many) and I wanted to create a solution where I used Zend_Controller_Router_Route to route all static content automatically through to a StaticController whose job it would be to include or render .phtml pages based on a controller/action pairing in the URL from some sort of directory like /layouts/staticpages
Because of SEO and various reasons I don't want to have the controller pairing in the URL for these static pages be visible as /static/page/page1... It has to be "real world descriptions" of the /section/page (eg. advantages/someadvantage )
Here is the problem: Using Zend_Controller_Router_Route can do the job when I set up the correct routes BUT it messes something awful with Zend Navigation... I assume because Zend_Navigaion doesn't play nice with on-the-fly controller/action switching.
Code example:
$router = Zend_Controller_Front::getInstance()->getRouter();
$route = new Zend_Controller_Router_Route('advantages/:page/*',
array('controller' => 'static', 'action' => 'display', 'mode' => 'advantages',
'page' => 'index'));
$router->addRoute('advantages', $route);
This handles the job of switching pages in the "advantages" section well enough, but Zend_Navigation's automatic controller/action writing AND the highlighting of "active" nodes ends up being all screwed up because it now thinks that its controller is "static" and action is "display".
Is Zend_Navigation fundamentally incompatible with Zend_Controller_Router_Route? Is there a better way of doing this single static page controller or handling static content across the board?
Since you are using one controller/action for all static pages, you must customize your Zend Navigation before displaying it.
Check Example 4 in the Zend Documentation.
// the following route is added to the ZF router
Zend_Controller_Front::getInstance()->getRouter()->addRoute(
'article_view', // route name
new Zend_Controller_Router_Route(
'a/:id',
array(
'module' => 'news',
'controller' => 'article',
'action' => 'view',
'id' => null
)
)
);
// a page is created with a 'route' option
$page = new Zend_Navigation_Page_Mvc(array(
'label' => 'A news article',
'route' => 'article_view',
'module' => 'news', // required for isActive(), see note above
'controller' => 'article', // required for isActive(), see note above
'action' => 'view', // required for isActive(), see note above
'params' => array('id' => 42)
));
// returns: /a/42
$page->getHref();