theo Posted February 11, 2018 Share Posted February 11, 2018 Hello Can I define what the title shows in page lister? Is it possible to combine the title with other field values or plain text? E.g Fields are Title: MyProduct Color: Red Can Page Lister show "MyProduct (Red)" ? Or Title: 22 Can Page Lister show "22 inch" ? Thank you. Link to comment Share on other sites More sharing options...
dragan Posted February 11, 2018 Share Posted February 11, 2018 Go to "edit template", select tab "advanced" and you'll see a settings section that looks like this: 3 1 Link to comment Share on other sites More sharing options...
theo Posted February 11, 2018 Author Share Posted February 11, 2018 Perfect! Didn't see that option... Thank you! Link to comment Share on other sites More sharing options...
kixe Posted February 11, 2018 Share Posted February 11, 2018 ... unlimited possibilities with a hook ... Code // ready.php $wire->addHookAfter('ProcessPageListRender::getPageLabel', function($e) { $listedPage = $e->arguments[0]; // ... $e->return = '...'; }); 8 1 Link to comment Share on other sites More sharing options...
theo Posted February 12, 2018 Author Share Posted February 12, 2018 Thank you. Can I have the same for the page title / heading? I'm sorry for asking stupid questions. Many things are obvious, some things are not. Link to comment Share on other sites More sharing options...
kixe Posted February 12, 2018 Share Posted February 12, 2018 49 minutes ago, theo said: Can I have the same for the page title / heading? Of course ... /** * modify headline in page edit interface */ $wire->addHookAfter('ProcessPageEdit::headline', function($e) { // get id of page beeing edited $pid = (int) $this->input->get('id'); if (!$pid) return; $pageBeeingEdited = $this->wire('pages')->get($pid); if (!$pageBeeingEdited->id) return; $headline = "My ID is $pageBeeingEdited->id"; $this->wire('processHeadline', $headline); // no need to modify the return value ($e->return) }); 4 1 Link to comment Share on other sites More sharing options...
theo Posted February 12, 2018 Author Share Posted February 12, 2018 Thanks Kixe. This works. I have never used ready.php before. Is there a way to use simple HTML in the headline? Like italic, bold etc. From a quick test, I see that it outputs tags as... tags. Link to comment Share on other sites More sharing options...
adrian Posted February 12, 2018 Share Posted February 12, 2018 Just wanted to explain @kixe's excellent answer a little for those who might be wondering why that hook isn't listed in the Tracy Captain Hook panel or on the Captain Hook page: https://processwire.com/api/hooks/captain-hook/ What is going on is that ProcessPageEdit extends Process and Process has a ___headline() hookable method. If you're used the Tracy Captain Hook panel, it always pays to check the class that the current class extends: Now we're looking at the hooks for the Process class and we can see that headline is available. Hope that helps! The other useful tip is the to click the "Toggle All" button at the top and CTRL/CMD +F and look for "headline" 7 Link to comment Share on other sites More sharing options...
adrian Posted February 12, 2018 Share Posted February 12, 2018 One tweak that I think is worth making is to use: $e->object->getPage() rather than $this->input->get('id') to get the page being edited. /** * modify headline in page edit interface */ $wire->addHookAfter('ProcessPageEdit::headline', function($e) { $pageBeeingEdited = $e->object->getPage(); if (!$pageBeeingEdited->id) return; $headline = "My ID is $pageBeeingEdited->id"; $this->wire('processHeadline', $headline); // no need to modify the return value ($e->return) }); 2 Link to comment Share on other sites More sharing options...
kixe Posted February 12, 2018 Share Posted February 12, 2018 @theo You can use html, but you'll need to create a new admin theme to accomplish this ... If the AdminTheme you are using extends the AdminThemeFramework class (UI-kit) or contains the AdminThemeDefaultHelper class, all tags are entity-encoded.https://github.com/processwire/processwire/blob/e73ec872da5f9db2960524dbb984287bfe4b7b4e/wire/core/AdminThemeFramework.php#L156 1 Link to comment Share on other sites More sharing options...
adrian Posted February 13, 2018 Share Posted February 13, 2018 7 hours ago, theo said: Is there a way to use simple HTML in the headline? Like italic, bold etc. It's kinda hacky, but this does work: $this->addHookAfter('Page::render', function($event) { if($this->process != 'ProcessPageEdit') return; $p = $this->process->getPage(); $headline = "My ID is $p->id"; $event->return = str_replace($p->title.'</h1>', '<strong><em>'.$headline.'</em></strong></h1>', $event->return); }); 2 1 Link to comment Share on other sites More sharing options...
theo Posted February 13, 2018 Author Share Posted February 13, 2018 Hehe, thank you adrian. Link to comment Share on other sites More sharing options...
theo Posted February 13, 2018 Author Share Posted February 13, 2018 Next question. Not sure if I should open a new thread for this. Can I show some "virtual hierarchy" in the backend? For example my real page hierarchy looks like P -Aa -Ab .. -Zz Can I show something like P -A --Aa --Ab .. -Z --Zz You see the letters of the alphabet, you can "open" them, as if they were pages, but in fact they aren't real pages. It is just for grouping things better. I could add real pages for each letter of the alphabet, but I'm not sure if this makes sense. It deepens the (real) structure with no obvious benefit, other than grouping. I hope you understand what I mean. I'm completely open to any kind of thoughts regarding this matter. Thank you. EDIT: Or sth. similar to paging. Instead of 1 2 3 there would be A B C or some other criteria? Link to comment Share on other sites More sharing options...
flydev Posted February 13, 2018 Share Posted February 13, 2018 (edited) On 12/02/2018 at 12:24 AM, kixe said: ... unlimited possibilities with a hook ... Hey @kixe thanks for this idea, I tried to implement it but I ran into an issue. I can't manage to set a different label depending on a condition. I think I must be missing something. The hook : $this->wire->addHookAfter('ProcessPageListRender::getPageLabel', $this, 'getPageLabel'); public function getPageLabel($event) { $listedPage = $event->arguments[0]; if($listedPage->template->name == 'tpl1' || $listedPage->template->name == 'tpl2') { $this->status = $this->getUpdateStatus(); foreach ($this->status as $key => $value) { $event->return = ($this->status[$key]['closing'] == -1 || $this->status[$key]['transactions'] == -1) ? '<span class="uk-label label-update-status-error">ERR</span> ' : '<span class="uk-label label-update-status-ok">OK</span> '; } } } Each page on the page-tree have the same label label-update-status-ok : Could you share a portion of code ? ? @theo sorry for hijacking your thread ? Edit: fixed, it was just bad logic in the foreach loop inside the hook. Thanks again @kixe it rocks ! Edited February 13, 2018 by flydev fixed 1 Link to comment Share on other sites More sharing options...
kixe Posted February 13, 2018 Share Posted February 13, 2018 @adrian 6 hours ago, adrian said: It's kinda hacky, but this does work: $this->addHookAfter('Page::render', function($event) { if($this->process != 'ProcessPageEdit') return; $p = $this->process->getPage(); $headline = "My ID is $p->id"; $event->return = str_replace($p->title.'</h1>', '<strong><em>'.$headline.'</em></strong></h1>', $event->return); }); Cool ... ... but you will get unexpected results if the page has no title and uses the name instead or whatever. I would replace $p->title with $this->wire('processHeadline') to get it more stable. $this->addHookAfter('Page::render', function($event) { if($this->process != 'ProcessPageEdit') return; $p = $this->process->getPage(); $headline = "My ID is $p->id"; $event->return = str_replace($this->wire('processHeadline').'</h1>', '<strong><em>'.$headline.'</em></strong></h1>', $event->return); }); @flydev $this->getUpdateStatus() // ? what's that? return? 1 Link to comment Share on other sites More sharing options...
flydev Posted February 13, 2018 Share Posted February 13, 2018 It just return a multidimensional array where I can check a value (key: 'closing' or 'transactions') and assign a different label. Link to comment Share on other sites More sharing options...
adrian Posted February 13, 2018 Share Posted February 13, 2018 5 hours ago, theo said: Can I show some "virtual hierarchy" in the backend? Maybe this module from @Robin S can help you achieve what you want" https://github.com/Toutouwai/VirtualParents Link to comment Share on other sites More sharing options...
theo Posted February 13, 2018 Author Share Posted February 13, 2018 19 minutes ago, adrian said: Maybe this module from @Robin S can help you achieve what you want" https://github.com/Toutouwai/VirtualParents Thank you adrian. This looks close and interesting, but I don't think it is very practical in my case. From what I understand reading the description, I would have to make two separate templates for every letter in the alphabet and the virtual parents would have to be real pages anyway. Am I right? Thank you. Link to comment Share on other sites More sharing options...
Robin S Posted February 13, 2018 Share Posted February 13, 2018 5 hours ago, adrian said: Maybe this module from @Robin S can help you achieve what you want" https://github.com/Toutouwai/VirtualParents 5 hours ago, theo said: This looks close and interesting, but I don't think it is very practical in my case. Yeah, that module wouldn't really be practical if you need more than one or two virtual parents. The Virtual Parents module was an experiment to answer the question "To what extent is it possible to trick ProcessPageList into showing a page structure that isn't real?" And now that I've tried it I can answer with "To only a very limited extent". ProcessPageList just isn't designed to support anything other than the real page tree and forcing it do otherwise is pretty painful. There have been several requests for a way to browse an alternative page structure. It will require a module that builds its own tree from scratch and doesn't rely on ProcessPageList. It's on my to-do list but it will be challenging and I'm not sure when I'll get to it. And bear in mind too that any module like this will come with other limitations - for instance, it wouldn't be possible to sort or move pages like ProcessPageList can because the page structure shown might have no resemblance to the real structure. 2 Link to comment Share on other sites More sharing options...
adrian Posted February 13, 2018 Share Posted February 13, 2018 @theo - you can always take the opposite approach: 1 Link to comment Share on other sites More sharing options...
theo Posted February 13, 2018 Author Share Posted February 13, 2018 Thank you adrian and Robin S. Changing the tree hierarchy is probably not the best idea, and it doesn't have to be for my case. A different idea is, to do it somehow like the pager. Instead of numbers, there could be letters of the alphabet or other categories. This would be less problematic imho. What do you think? Link to comment Share on other sites More sharing options...
Robin S Posted February 13, 2018 Share Posted February 13, 2018 23 minutes ago, theo said: A different idea is, to do it somehow like the pager. Instead of numbers, there could be letters of the alphabet or other categories. As before, you can't easily modify ProcessPageList for this purpose. But you can use Lister (Pages > Find). So in your case you would filter according to some parent or some template, plus filter by "title starts with" some character. I have a module under development that will allow for a list/tree that dynamically changes the selector used by Lister. Not sure when it will be ready but that might end up being helpful for your scenario. 1 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now