Jump to content

How to link text to Lister pages?


LAPS
 Share

Recommended Posts

Hi,

I bookmarked a number of custom Listers (path: /admin/page/lister) and I have some doubts on how to use them.

In particular, I would like to link a custom Lister page in front-end content. I could make this by inserting a link within the body field (CKEditor) of a my page and using the URL of the Lister (e.g. /admin/page/lister/?bookmark=1514677991) so to render a linked text in the front-end.
My doubt: is the use of that URL the right way for linking text to a Lister?

I also would like to access the title data of the custom Lister in order to output the title as linked text in the front-end.
How can I do that (note: I am using the Hanna Code module for my body field)?

I have not found the relevant documentation that serves my case.

Link to comment
Share on other sites

Hi LAPS

I think Lister was designed for back-end use and will check if the user has proper permissions. Haven’t done that before but you can try to create a new role add the page-lister permission and add that role to the guest user. 

However, what is in your lister what can’t be rendered with PW’s API? Do you need just the table result or the form with all the search fields as well?

  • Like 1
Link to comment
Share on other sites

That's right. Lister was never meant to be used in the frontend.

If you just want to use Lister to create a selector, you just turn on debug mode and you'll see a yellow-highlighted text at the bottom of the Lister result screen with your current selector, i.e. 

template=52, teamLangSkills=1084, address%=zürich, limit=25, sort=lastName, include=unpublished

You can use the exact same selector of course in the frontend too.

Not sure why you want to use Hanna Code for that. But in plain PHP, you'd just do:

$selector = 'template=52, teamLangSkills=1084, address%=zürich, limit=25, sort=lastName, include=unpublished';
$pgs = $pages->find($selector);
if($pgs) {
	$out = '<ul>';	
	foreach($pgs as $p) {
		$out .= "<li><a href='{$p->url}'>{$p->title}</a></li>";	
	}
      $out .= '</ul>';
	echo $out;
}

I guess you can store this inside a Hanna block.

I don't know how you can directly access a certain Lister bookmark selector, but I'm sure it's possible.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...