How to use Page Selector in Custom Block?
PermalinkI'm totally new to concrete5 and try to wrap my head around... well everything.
I've build a custom block with some input fields, where the user should have the possibility to pick a page or write in in external link into a field. Now that works just great with the standard link picker coming with concrete5.
But that's where my problems start:
1.) Can i get the link picker functionality into my custom block (so i'm able to do it with add.php and edit.php)?
OR
2.) Can i use the page selector class to accomplish this?
http://concrete5.org/api/class-Concrete.Core.Form.Service.Widget.Pa...
This gets me the page selector where i can select a page from the sitemap, but haven't figured out yet how i can my hands on the URL Path to the selected page.
$html = Core::make('helper/form/page_selector'); print $html->selectPage('page_link');
As said the best solution would be the standard link picker, but i haven't figured out yet how to implement this into my custom block.
Any of you guys? I don't need a complete solution, maybe just a hint to a block or concrete5 addon which i has that functionality, so i can just analyze the code.
Thanks in advance!

Sorry for the rather bad english, with "standard link picker" i mean the functionality from the WYSIWYG Editor, where you can select a word and put a link on it. Hope this is a clearer statement.
Now i'm hooked up on the concrete5 events which get fired when doing stuff, i can see the object in my dev console, but don't know how to access it. In that object is everything i need, please see the attached screenshot. Is that prototype?
I figured i need to use the eventlistener, but don't get the object back i need.
Concrete.event.bind('ConcreteSitemap', function(e, instance) { Concrete.event.bind('SitemapSelectPage', function(e, data) { console.log(data); }); });
As said, this doesn't give me the object i need but it gets me some other object with cID, pagetitle and some DOM Sets from the page selector sitemap itself. Maybe it's the wrong event listener?
$pageSelector = Loader::helper('form/page_selector'); echo $pageSelector->selectPage('linkCID', $linkCID, 'ccm_selectSitemapNode');
When the block is saved, the page's ID will be stored in the db in that field. When you come to the view.php you should be able to just do
$nh = Loader::helper('navigation'); $page = Page::getByID($linkCID); $url = $nh->getCollectionURL($page);
No need for events or anything like that, it will all be handled within the block.
Still... does someone know how i can access those objects coming back from the cms? Could be very helpful in the future.