Leben++

It's never too late to get a life!

Better usability when switching between detail and list views

You can enhance the usability of your web page or application when redirecting from a detail view back to a list view by scrolling the list to the entry that was just edited. This is done with a fragment identifier in the URL, also called "anchor" and a matching id in each of the entries in the list.

Let's say your list view looks like this:

<div id="entry_1">
  Big chunk of text 1.
</div>
...
<div id="entry_42">
  Big chunk of text 42.
</div>

To scroll the list to entry number 42, you must create a URL like this: http://example.com/#entry_42

However, the standard URL and redirection helpers like gotoSimpleAndExit in the current Zend Framework release don't have a parameter for fragment identifiers. But it's possible to use gotoUrlAndExit and add the fragment to a generated URL:

$url = $this->_helper->url('index', 'entries').'#entry_'.$id;
$this->_redirector->gotoUrlAndExit($url, array('prependBase' => false));

The prependBase is important, otherwise the base URL will be added twice, if you have it configured.

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Keine HTML-Tags erlaubt
  • Zeilen und Absätze werden automatisch erzeugt.
By submitting this form, you accept the Mollom privacy policy.
Inhalt abgleichen