Sharing my custom (multi) page selector attribute types

Permalink 4 users found helpful
I made a package containing two page selector properties. They are much like the existing Page selector attribute already available in the marketplace, however these have more settings.

You can choose the root page under which only pages can be selected, as well as whether the user is allowed to select pages from sublevels further down.

Also, and maybe the best of all, finally there is an attribute that allows selecting multiple pages! It works somewhat like a "select" attribute.

If you create a website where pages with custom attributes are objects, like events or items in a shop, having an attribute that lets you associate on or more of those objects with each other is really a must for building a more complex site. This is what these attributes try to achieve.

I'd say it's still in beta version. It works, but I didn't work on the search capabilities yet, so that might not work. Also, the page selector popup is a bit crude. At the moment it's good enough for what I need it for.

I might submit this to marketplace if I get it in proper shape, meanwhile here's a link where you can download it. I'd like to hear if you have suggestions, comments, improvements or can help out with something.

UPDATE: changed to new url! (or alternatively download the attachment to this post, both are the same file) I have included Sadu's bugfix as well.

1 Attachment

View Replies:
vGibson replied on at Permalink Reply
Thanks, I'll download it and check it out. Sounds interesting...
Ronald72 replied on at Permalink Reply
Thank you! This is an important feature imho.

Do you have any plans making it work with the multilanguage feature in some way?
programmieraffe replied on at Permalink Reply
Really useful, thanks a lot!
programmieraffe replied on at Permalink Reply
Does somebody know how I can filter a page list by the multiple page selector attribute?

$pageList = new PageList();
$pages = $pageList->get();

"programmpunkt_akteure" is a multiple page selector attribute.

Help appreciated! :)
Dutchwave replied on at Permalink Reply
That would be a great thing to have. You would be able to setup related pages in a manual way that's very user friendly.
duststorm replied on at Permalink Reply
I've not been using concrete5 for some time now and I didn't do any new work on this script.
Maybe it needs to be updated a little to work with the latest versions, I have not tested it in a while.

Feel free to improve on it.
SkyBlueSofa replied on at Permalink Reply
I have a client that would like this functionality integrated with one of my addons, Page List Plus. After reviewing it for a bit, it seems to work wonderfully.

I think there would be a lot of people that would be interested in using this addon, but might not be able to find it since it's not in the Marketplace. Would you be interested in submitting it and supporting it in the Marketplace? If not, would you be willing to let me submit and support it as a free addon in the Marketplace?

buurvrouw replied on at Permalink Reply
Hi there,

Can someone help me how to display the multiple values of this attribute in a page?

I've used the multiple page selector attribute, but just the first value is displaying when using this code in my template:

$mLink = $c->getAttribute('materialen'); //Custom Page Select Attribute for the Page URL
   $mPage = Page::getByID($mLink); //Using the ID that Page Select Attribute returns, get the collection associated with it
   $mUrl = $mPage->getCollectionPath(); //Get the URL to the sitemap page for the Page ID
   $mNaam = $mPage->getCollectionName(); //Get the PageName to the sitemap page for the Page ID
<a href="<?php echo $mUrl ?>" title="<?php echo $mNaam ?>"><?php echo $mNaam ?></a>

And when just using this, i just get the text 'Array':

$materialen = $c->getCollectionAttributeValue('materialen'); //Custom Selection attribute
echo $materialen;
A3020 replied on at Permalink Reply
You need to iterate over the array. For example:

$materialen = $c->getAttribute('materialen');
  foreach($materialen as $pageID){
     $page = Page::getByID($pageID);
       echo $page->getCollectionID();
duststorm replied on at Permalink Reply
Hello Dave.
Since I currently am not developing with Concrete5, I cannot commit to actively maintaining this little project. But you are free to maintain a version of it on the marketplace. I would appreciate it if I was credited somewhere (My name is in the controller.php file), but it is not required.
If I remember well, it is also based on the page select widget that is in the marketplace, so undoubtedly some credits go to the original author as well.
A3020 replied on at Permalink Reply
@duststorm, thanks for sharing. I was looking for an attribute to select multiple pages and your plugin is still working in version
Sadu replied on at Permalink Reply
Thanks for this, I found it helpful.

I'd just like to share a bugfix.

I found that if a page has an apostrophe in the page name then it can't be selected in the list.

The fix is to escape these characters before displaying.

Change line 70 of tools/simple_sitemap.php to...
$html .= '<li><a href="javascript:void(0)" onClick="'.$callback.'('.$oChild->getCollectionID().', \''.str_replace("'", "\\'",$oChild->getCollectionName()).'\');">' . $oChild->getCollectionName() . '</a>';

and line 99 to...
echo '<a href="javascript:void(0)" onClick="'.$callback.'('.$oFirstLevelChild->getCollectionID().', \''.str_replace("'", "\\'", $oFirstLevelChild->getCollectionName()).'\');">' . $oFirstLevelChild->getCollectionName() .'</a>';
mhistihori replied on at Permalink Reply
Thank you... you save my time...
magpie replied on at Permalink Reply
This is great. One question, how could I use this in a custom block?
duststorm replied on at Permalink Reply
Hi everyone.
I'm happy that others have found this useful. Personally I have not been very active on these forums, or have not maintained the project because I currently have no projects involving Concrete5.
It's good to hear that it still works in newer versions, though.

Because soon the webhost that is currently holding the file will disappear I have uploaded it to another more permanent space. I have taken this opportunity to include the fix that Sadu posted.

Also, feel free to fix things and post new versions of it.

Edit: I noticed that I could now attach the file to the post as well. So you can download it either from the attachment or from the new URL.
A3020 replied on at Permalink Reply
Is this add-on packaged up for the marketplace yet? I'm using it quite regularly and find it very useful!
duststorm replied on at Permalink Reply
To my knowledge, it isn't.
mesuva replied on at Permalink Reply
Seeing this older thread pop up is quite strange to me, as I was thinking this week of pushing to github (or maybe the marketplace for free) a multi page selector I built myself - I'd not seen this one!

What's even weirder is that I'd also called my attribute 'multi_page_selector'.
Mine doesn't have the ability to limit to a part of the sitemap, but it does allow a drag and drop re-ordering of the pages and a couple of different ways to return the data.

It looks like this in action:

Anyone keen on this?
Sadu replied on at Permalink Reply

I would say that being able to limit the selection to a branch of the sitemap is essential.

I use these selectors to allow the user to select some category pages, or some blog pages, or some other custom page.

Pretty much always those pages sit in a particular part of the sitemap and I don't want the user randomly choosing any old page.

Also being able to limit by page type would be very handy.

Good luck - I'd love to see this in the marketplace :)
mesuva replied on at Permalink Reply
Thanks for the thoughts. I agree that it would be very useful to have the ability to restrict to parts of the sitemap or page types, but at the moment I'm using concrete5's standard page selector widget, which doesn't have these display abilities (that I'm aware of).

I notice that duststorm's has it's own version of the sitemap for selecting a page, so that's how it handles this filtering.

So I'm torn between using the standard sitemap (which has search features, is less work/maintenance and has other niceties), versus being able to restrict selection.

Thinking, thinking...
A3020 replied on at Permalink Reply
I'm just encouraging people to submit free add-ons and more specifically custom attribute types, because there aren't many available.

I think sorting pages is an awesome feature!
Nanco replied on at Permalink Reply
I've been playing around with the multiple page selector attribute (great idea!) and would love to substitute the default page selector option in the page list block with it.

Can anyone help steer me in the right direction with achieving this? Haven't had much luck so far.