benbyf

New module MarkInPageTree

Recommended Posts

MarkInPageTree

New module which does what it says in the title. It adds an icon to a page on the page tree if -> a specific field is true and / or is a specified template.

For example I'm using it to add an icon to any page that has a checked (checkbox) exclusive field. This helps with admin clarity as you can see instantly which pages of the same template have differing content (i.e. are exclusive or not).

https://github.com/benbyford/MarkInPageTree

Screenshot 2016-12-09 14.33.45.png

  • Like 10

Share this post


Link to post
Share on other sites

How about using InputfieldSelector for the page selection and using InputfieldIcon for the icon selection?

  • Like 2

Share this post


Link to post
Share on other sites
Just now, LostKobrakai said:

How about using InputfieldSelector for the page selection and using InputfieldIcon for the icon selection?

Sure, how does one do that :)

Share this post


Link to post
Share on other sites

couldnt work it out, just gave me a field for searching the pages on the site but not selecting them... and it wouldnt show templates or fields.

I was able to use select multiple instead thought. For example:

$f = $this->modules->get('InputfieldSelectMultiple');
$f->attr('name', 'template');
$f->description =  $this->_("Template or templates of pages to trigger bulk email to users after new page published");
$f->addOption('', '');

foreach($this->templates as $template){
$f->addOption($template->name, $template->title);

 

Share this post


Link to post
Share on other sites

Updated and works well (needed to delete the extra fa- in the html as the icon selector adds the complete fontawesome name). Only thing I would change but unsure is whether you can have or selector somehow as it currenlty only adds icons to the selectors found pages not a template or a field for example. i.e. for mulitple selectors.

Share this post


Link to post
Share on other sites

Great idea and great module! Saves me some rather ugly additions to the displayed title page in the page tree.

One thing for the Christmas wish list: It would be even greater if the module would provide a way to set up several different rule sets. So you could set up different icons to mark different things.

  • Like 2

Share this post


Link to post
Share on other sites

not really sure how to make this happen... repeater? Anyone point me in the right direction to creating multiple additional fields to the module settings? so the module can have as many icon and template or field pairs as you want...?

Share this post


Link to post
Share on other sites

Multi-value fields in module config is a bit tricky, because almost everything multi-value in pw is based on pages, which you don't use here. It's probably simplest to add an integer field "number_of_configuration", which does, after it's saved, cause the field(s) for the page selection to be rendered that many times. In your modules code you'd also use that number for determining how often to loop though potential configurations.

Share this post


Link to post
Share on other sites

I would go with the "icon name = selector" route, in a simple textarea, one rule per row. Icon name would be the fontawesome name.

  • Like 2

Share this post


Link to post
Share on other sites

Happy Christmas everyone!

I had a bit of time to add tot his module :)

It now has textareas (thanks @tpr) in it's config which means it can now add as many icons and field and/or template pairs as you like. This means you could add one icon for pages of the template basic-page, and also add another icon for all pages with a counter etc...

Also... I've added a third textarea, allowing you to add a list of fields to show the data for IN the pagetree itself (see image below). In my example below I am able to show in the page tree by each page if they have a counter what the data is and whether the page has a field exclusive and its data.

Thanks for peoples help and hope it is useful. (updated on github)

Screenshot 2016-12-17 15.43.47.png

Screenshot 2016-12-17 15.43.27.png

  • Like 5

Share this post


Link to post
Share on other sites
4 minutes ago, Juergen said:

Hello @benbyf

can you check the following message:

Screenshot_2.jpg

Thanks!

when are you getting this error? can you send me your settings. thanks

Share this post


Link to post
Share on other sites

No its a notice - it only shows up  as an error because I am running Tracy in strict mode.

These are my settings:

Screenshot_3.jpg

  • Like 1

Share this post


Link to post
Share on other sites

As a quick patch this fixes the error:

Change this:

$a[trim($cropItems[1])] = trim($cropItems[0]);

 

To this:

if(count($cropItems) > 1){
	$a[trim($cropItems[1])] = trim($cropItems[0]);
}

 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks, and glad you're finding the module useful.

If you have any other bugs or fixes, please submit a issue or pull request on github

Share this post


Link to post
Share on other sites

Hi,

Thanks for this module, it's quite useful, and it's work very well. However, I still wondering which icons I can use? I can't find anywhere a list or a reference to an iconset used by the module. 

Mel

Share this post


Link to post
Share on other sites

Great module, thank you!

Is there a way to use separate variations of icons, e.g. "fas fa-check" vs. "far fa-check"?

P.S.: You might want to point to the icon cheatsheet in the module description. I was confused as well (newbie).

Share this post


Link to post
Share on other sites
On 9/7/2018 at 10:34 AM, Knubbi said:

Great module, thank you!

Is there a way to use separate variations of icons, e.g. "fas fa-check" vs. "far fa-check"?

P.S.: You might want to point to the icon cheatsheet in the module description. I was confused as well (newbie).

Both valid. PW comes with Fontawesome in the default admin so thats why its the deafult far icons. If you want to purchase new icons versions and replaces the files in your copy then that shoul work.

Will definitely change the description.

  • Like 1

Share this post


Link to post
Share on other sites

Hi Benbyf,

I'm really enjoying this module.  It really helps visualize how the page tree relates to the templates.  I'm using "template" in Data.

One request: It would be really helpful if you could add a permission so that only super users see the MarkInPageTree stuff in the Page Tree by default.  If other roles need to see the MarkInPageTree stuff in the Page Tree, a site admin could add a MarkInPageTree permission to that role.

The only caveat is that existing sites that have already installed this module will need to be updated to use the new permission.

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Sebi
      I've created a small module which lets you define a timestamp after which a page should be accessible. In addition you can define a timestamp when the release should end and the page should not be accessable any more.
      Github: https://github.com/Sebiworld/PageAccessReleasetime
      Usage
      PageAccessReleasetime can be installed like every other module in ProcessWire. Check the following guide for detailed information: How-To Install or Uninstall Modules
      After that, you will find checkboxes for activating the releasetime-fields at the settings-tab of each page. You don't need to add the fields to your templates manually.
      Check e.g. the checkbox "Activate Releasetime from?" and fill in a date in the future. The page will not be accessable for your users until the given date is reached.
      If you have $config->pagefileSecure = true, the module will protect files of unreleased pages as well.
      How it works
      This module hooks into Page::viewable to prevent users to access unreleased pages:
      public function hookPageViewable($event) { $page = $event->object; $viewable = $event->return; if($viewable){ // If the page would be viewable, additionally check Releasetime and User-Permission $viewable = $this->canUserSee($page); } $event->return = $viewable; } To prevent access to the files of unreleased pages, we hook into Page::isPublic and ProcessPageView::sendFile.
      public function hookPageIsPublic($e) { $page = $e->object; if($e->return && $this->isReleaseTimeSet($page)) { $e->return = false; } } The site/assets/files/ directory of pages, which isPublic() returns false, will get a '-' as prefix. This indicates ProcessWire (with activated $config->pagefileSecure) to check the file's permissions via PHP before delivering it to the client.
      The check wether a not-public file should be accessable happens in ProcessPageView::sendFile. We throw an 404 Exception if the current user must not see the file.
      public function hookProcessPageViewSendFile($e) { $page = $e->arguments[0]; if(!$this->canUserSee($page)) { throw new Wire404Exception('File not found'); } } Additionally we hook into ProcessPageEdit::buildForm to add the PageAccessReleasetime fields to each page and move them to the settings tab.
      Limitations
      In the current version, releasetime-protected pages will appear in wire('pages')->find() queries. If you want to display a list of pages, where pages could be releasetime-protected, you should double-check with $page->viewable() wether the page can be accessed. $page->viewable() returns false, if the page is not released yet.
      If you have an idea how unreleased pages can be filtered out of ProcessWire selector queries, feel free to write an issue, comment or make a pull request!
    • By David Karich
      Thanks to the great Pro module "RepeaterMatrix" I have the possibility to create complex repeater items. With it I have created a quite powerful page builder. Many different content modules, with many more possible design options. The RepeaterMatrix module supports the cloning of items, but only within the same page. Now I often have the case that very design-intensive pages and items are created. If you want to use this module on a different page (e.g. in the same design), you have to rebuild each item manually every time.
      With this proof of concept I have created a module which adds the feature to copy a repeater item to the clipboard so that you can paste this item to another page with the same repeater field. The module has been developed very rudimentarily so far. It is currently not possible to copy nested items. There is also no check of Min/Max. You can also only copy items that have the same field on different pages. And surely you can solve all this more elegantly with AJAX. But personally I lack the deeper understanding of the repeaters. Also missing on the Javascript side are event triggers for the repeaters, which would make it easier. Like e.g. RepeaterItemInitReady or similar.
      it would be great if @ryan would implement this functionality in the core of RepeaterMatrix. I think he has better ways to implement this. Or what do you think, Ryan?
      Everybody is welcome to work on this module and improve it, if it should not be integrated into the matrix core. Therefore I put it for testing and as download on GitHub: https://github.com/FlipZoomMedia/InputfieldRepeaterMatrixDublicate
      You can best see the functionality in the screencast: 
       
    • By anderson
      Hi,
      Please take a look at this:
      https://templatemag.com/demo/Good/
      The upper nav bar, including dropdowns like "pages" and "portfolios", what do you call this whole thing? At first I guess it's called "dropdown nav bar", but seems not.
      AND of course, what's the simplest way/module to achieve this in PW?
      Thanks in advance.
    • By Sebi2020
      Hey, I'm new and I created a simple module for tagging pages because I didn't found a module for it (sadly this is not a core feature). This module is licensed under the GPL3 and cames with absolutly no warranty at all. You should test the module before using it in production environments. Currently it's an alpha release. if you like the module or have ideas for improvements feel free to post a comment. Currently this fieldtype is only compatible with the Inputfield I've created to because I haven't found  an Inputfield yet, that returns arrays from a single html input.
      Greetings Sebi2020
      FieldtypeTags.zip.asc
      InputfieldTagify.zip
      InputfieldTagify.zip.asc
      FieldtypeTags.zip
    • By psy
      Background
      I'm creating a module to integrate https://pushalert.co/ into ProcessWire. You actually don't even need a module. You could just use the "Other Websites" javascript provided by PushAlert for basic functionality, ie send a broadcast notification to all subscribers. This is essentially what all the other integrations, including WordPress, do. The WP integration installs a widget with a form enabling the admin to enter details such as title, message, etc from a blog post. It does not:
      collect any statistics within the CMS about the notification enable audience fine tuning to eg a particular subscriber or subscriber segment within WP. The admin needs to use the PA dashboard for that functionality PushAlert has a javascript and REST API. It's intended that this module will use both. https://pushalert.co/documentation 
      What my module does so far:
      associate a subscription with a user. FE user clicks a button on the website front end to subscribe and/or agrees to the browser popup to accept notifications from this site send broadcast push alerts from a page within admin It doesn't have a 'widget' but easy enough to create a fieldsetpage with the relevant fields and add that fs page to any appropriate templates, then with a hook, send the notification. Need to be careful that once published/sent, the notification is not automatically re-sent on subsequent page edits.
      Looking for help/collaboration on how best:
      to send a notification, eg from a blog post, then track the statistics. Dilemma is that the push notification must come from the admin page. Responses go to the sending page which, as it's an admin page, is restricted and will not accept the https response. This is where the other CMS integrations stop. The only json response from PushAlert is the status, eg 'success', and the notification id. There is no opportunity at this point to capture the sending page id. handle, 'once sent on page publish', do not automatically resend on future page edits Am thinking along the lines that FS Page will have a @kongondo runtime markup field https://modules.processwire.com/modules/fieldtype-runtime-markup/ to pull the stats from PushAlert. Every time an admin visits the page, the stats will update.
      Once an admin checks the 'Send notification on page publish' checkbox, a hook creates new front end page that records the 'sender page', sends the notification request to PA, which then uses that newly created frontend page, as the response endpoint. Another rook re-associates the front end page with the admin page (eg blog post), to update the stats.
      Potential use cases:
      Notify individual and/or users with a particular role of an event, eg "New work opportunity" for job seekers; new blog post published; entries now open, etc...
      Looking for help/ideas/collaboration on this module. Please let me know if you're interested and as I do, believe this would be a great addition to ProcessWire