Add Route to ajax Link? - zend-framework

I am still very new to Zend Framework and work on my first small Project. I have now come across from Routing, which is a great tool. Unfortunately I do not get it to run on my Ajax Link. I also can't find any information about it. Is there a way to add routes to an Ajax Link? Thank you very much in advance for any hint. Below is my try, but no sucess.
echo $this->ajaxLink("Remove",array('article' =>$this->escape($entry->id),'deleteB',true),

your ajax link should point just as normal link to the action in your controller. The only thing you need to do is disable rendering view which is by adding:
// path/ExampleController.php
public function removeAction()
{
// Disable layout
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
// Your code to remove goes below
}
In my opinion ajax does not need special route. Hope that helps somehow

In the docs there doesn't seem to be any info on passing a route name as a parameter, at least I cannot find any - I'd be happy to be proven wrong.
I guess you can work around this problem for now, constructing the $url with the url() view helper and passing it then to the ajaxLink helper. Check out the ZF documentation page to make sure you pass the right parameters in the right places.

Related

Page Navigation in GWT Application

I want to navigate to another page in my application. I don't want the page to reload(i.e.. application should be a single URL application).
I know only one way to accomplish this by changing the proper div attached in the RootPanel by whatever data I want to display. But I fell that might get cumbersome if there are many navigations(I haven't tried it though :P).
Is there any other way to accomplish this or make the above said approach better?
Thanks in advance.
I guess you need GWT Development with Activities and Places
Well ,its time to have a look on MVP
With that you can do
History.newItem(tokenOfYourPresenterScreen);
A nice single EntryPoint demo app is here : (BrowserHistoryExample.java)
http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsHistory.html
I added the below to the example to demonstrate links.
vertPanel.add(new Label("Access history via Hyperlinks"));
vertPanel.add(new Hyperlink("External Page 0","page0"));
vertPanel.add(new Hyperlink("External Page 1","page1"));
vertPanel.add(new Hyperlink("External Page 2","page2"));

Setting Page Title - headTitle() - Zend Framework 2 ZF2

I am currently in the process of building an application with ZF2, everything is going well so far, but I am just having trouble with the page titles (as in the <title> tag in the <head>).
In my layout.phtml I have it statically set a string using $this->headTitle().
I want it to basically include the name of the module, controller and action by default, just like the doc page suggests:
http://framework.zend.com/manual/2.1/en/modules/zend.view.helpers.head-title.html
However when I try and implement the example code, I get an Exception.
Frankly the documentation should at least show you the best place to put this code.
I am looking for an example that a ZF2 noob can follow. I basically want to place some code somewhere (presumably Application\Module.php) so that I can set the default title as "Module - Controller - Action", then I need an example of how to override it easily from each controller or view (whichever is preferred)... please help! :)
As per Sams comment...
Readthedocs has the working example: http://zf2.readthedocs.org/en/latest/modules/zend.view.helpers.html#headtitle-helper
Thanks for your help Sam!

Duplicate URLs in Zend

I am developing a ZF website: howtowritecitations (dot) com
and it has a TOS page:
howtowritecitations (dot) com/termsofservice
But what are these duplicate pages?
http://www.howtowritecitations.com/termsofservice/index
http://www.howtowritecitations.com/index.php/termsofservice
http://www.howtowritecitations.com/index.php/index/termsofservice
Where did they come from? Will this be a problem? I hope not. For example, when Google crawls the page, it will only find and index howtowritecitations (dot) com/termsofservice, right?
If it is a potential problem, show me in the right direction so I can try and solve it.
Someone suggested to start looking at getRequestUri() in routeShutdown() (or something similar)
to use preg_replace to remove index.php, in order to 301-redirect to the proper URL, but I lost here.
Thanks in advance for advice or comments
This is caused by the routes you have setup. By default, Zend Framework applications usually route like:
www.yoursite.com/:controller/:action/:param
Right now, your termsofservice controller located at www.yoursite.com/termsofservice when called will show the :index action by default when no action is specified without changing the URL. It is also perfectly valid to access it using www.yoursite.com/termsofservice/index.
In order to fix these, you need to setup custom routes where everything that matches www.yoursite.com/:controller/* will route to www.yoursite.com/:controller. That way Google will never get a chance to see an alternate URL to index.

Why no Zend_Layout helper or codebehind? And best way to

I was just wondering why no code-behind or helpers were made to work with layouts? I have stuff I want to display in my layouts without having to set it up in a placeholder for every single controller.
I was also wanted to know what is the best way to persist a display-once "success-message" across many pages. For example, a user fills out a form and when it is submitted correctly they are redirected to another page. I want the user to see a success message on that other page. Is there some sort of provision in Zend Framework that makes this easier?
Well for the messages you can use the Flash Messenger helper
As far as setting up the place holders you could use a base controller and set these up in the init method overriding on descendents when necessary.

How should I use <a href> tag to access other templates in lift?

According the Lift wiki, I know the "View First" concept of Lift. That's very different from any framework I used. Take the basic JSP things as the example, I could write
Create a new post
in the page, and write the logic in a servlet. How can I do things like this with lift? I wrote the same tag in a template and when I accessed this page I got 404 error. But if I add a Menu to the SiteMap, things goes well. Is there any possible to make a link without making a new Menu? I am a beginner of Lift and Scala. Thanks in advance.
When everything is declared in your SiteMap, you can have Lift generate the links for you.
Yes, it is possible.
Just don't call LiftRules.setSiteMap at your boot class, then Lift will let you access every pages under your webapp/ directory. You could test your code in this mode.
But this will also lead to no access control, so be careful.
It is also possible to do what I think you asked, which is to make the link accessible, but not visible in the SiteMap (if you don't want the SiteMap at all, go with Brian's answer), with code like this:
SiteMap(Menu("PreClass") / "preClass" >> Hidden)
We prefer to leave the SiteMap enabled as tightly controlling access seems like a good idea in our case.