Jump to content
nik

PageReferencesTab

Recommended Posts

Page References Tab

This little module adds a new tab, References, to the page editor. There it lists pages referencing the page that is being edited (title, path, field). There are also links to view or edit the listed pages (if they're viewable/editable).

Only fields of type FieldtypePage are considered to be references and system fields are not listed at all (roles, permissions).

It's nothing much, but as the subject has turned up a couple of times in the forums, I decided to give it a try. So watch out what you're asking!

Screenshot

post-481-0-27506600-1362508112_thumb.png

Links

Modules directory: http://modules.processwire.com/modules/page-references-tab/

GitHub: https://github.com/niklaka/PageReferencesTab

  • Like 18
  • Thanks 1

Share this post


Link to post
Share on other sites

Cool idea but isnt it too disconnected from the page fields? I have somthing similar but inside below the page select.

Share this post


Link to post
Share on other sites

I did think of other ways to approach this, but couldn't come up with anything clearly better than what I have now. Initially I was thinking of a fieldtype, but somehow I don't (yet) like the idea of a fieldtype with no data of its own.

Actually, I don't quite understand what you're saying about how you've solved this yourself :). Page select? Where?

Still this is just one possible approach and I'm more than willing to change it to something else if someone would come up with a silver bullet or something like that.

Share this post


Link to post
Share on other sites

Ahh sorry, should've seen it, I was talking about page references themself showing links to the linked pages :) Your's is the other way round... got it. :D 

  • Like 1

Share this post


Link to post
Share on other sites

Great idea and module Nik! This will actually be quite handy on a site I'm working on right now. 

Share this post


Link to post
Share on other sites

Certainly useful for larger sites and I can think of at least one that would make use of this.

Share this post


Link to post
Share on other sites

Updated version of this module just found its way into GitHub.

Now there's a config option "Enabled templates" letting you choose the templates you want the "References" tab to be added to (when editing a page with those templates). If no template is chosen, "References" tab is always shown. Templates with system-flag are always skipped, like fields with system-flag have been from the beginning.

  • Like 3

Share this post


Link to post
Share on other sites

Great addition nik! Really useful module since I work a lot with Page fieldtypes!

Share this post


Link to post
Share on other sites

When switching templates (it doesn't matter which or of the page reference tab has been enabled) on pages I'm getting errors:

Notice: Trying to get property of non-object in /home/x/x/x/site/modules/PageReferencesTab/PageReferencesTab.module on line 65

Notice: Trying to get property of non-object in /home/x/x/x/site/modules/PageReferencesTab/PageReferencesTab.module on line 71

Warning: Cannot modify header information - headers already sent by (output started at /home/x/x/x/site/modules/PageReferencesTab/PageReferencesTab.module:65) in /home/x/x/x/wire/core/Session.php on line 358

Warning: Cannot modify header information - headers already sent by (output started at /home/x/x/x/site/modules/PageReferencesTab/PageReferencesTab.module:65) in /home/x/x/x/wire/core/Session.php on line 359

Warning: Cannot modify header information - headers already sent by (output started at /home/x/x/x/site/modules/PageReferencesTab/PageReferencesTab.module:65) in /home/x/x/x/wire/core/Session.php on line 360

Any pointers why this error might occur? It does save the chosen template on the page. I'm running 2.3.0.

  • Like 1

Share this post


Link to post
Share on other sites

I just installed this module and got exactly the same errors. 

  • Like 1

Share this post


Link to post
Share on other sites

Line 65 seems to include a single &. Changing this to && doesn't matter. 

Share this post


Link to post
Share on other sites

Works just like a charm here.

Share this post


Link to post
Share on other sites

Line 65 seems to include a single &. Changing this to && doesn't matter. 

Nothing wrong there, this is bitwise operator http://www.php.net/manual/en/language.operators.bitwise.php

Ther error says 

$this->editedPage

is not an object... so maybe even the line before fails for you for unknown reasons

$this->editedPage = wire('pages')->get((int)$this->input->get('id'));

can you try replace #62 with

echo wire('pages')->get((int)$this->input->get('id'));
exit;

And refresh page and see what output?

  • Like 1

Share this post


Link to post
Share on other sites

I've seen the bitwise operates before, but I don't totally understand this soma. I've narrowed it down a little bit more. Changing a template which doesn't result in the deleting of any fields doesn't throw an error.

Replacing line 62 with your code results in an empty page (double checked no output at all). It seems getting stuck at:

http://domainname.com/processwire/page/edit/saveTemplate

I'll try and disable some other modules which might be infering with this one.

Share this post


Link to post
Share on other sites

Ah sorry missed the change temple part... now it's more obvious a bug ;)

  • Like 1

Share this post


Link to post
Share on other sites

No worries. It's getting late here. I will try to find out more tomorrow.

Share this post


Link to post
Share on other sites

The fix would be easy to add this before line #62

if(!$this->input->get('id')) return;
  • Like 2

Share this post


Link to post
Share on other sites

Thanks @arjen & @adrian for the report. And thanks @soma for giving the right solution :). It definitely was a bug in this very module.
 
I've updated the module to check id has been given as a GET parameter before using it to get the page being edited. This seems to solve the problem you guys were facing, just like soma said. New version is in GitHub and version number has been updated in the modules directory as well.
 
@arjen: Soma was right also regarding that bitwise-and (naturally ;)). That line, and two similar ones elsewhere, checks if the template has the system flag set. Property 'flags' of a template is a bit field where there's possibly more than one flag (bit) set at a time. So it wouldn't be correct for example just to see if the flags value equals to the value of system flag, but it has to be done using a bitwise operator.

Sidenote: actually in this very case there's only the system override flag that could co-exist with the system flag, but still that's the correct way of checking if a flag has been set :).

  • Like 3

Share this post


Link to post
Share on other sites

Nik, I've updated the module and it works great! Thanks for updating the module.

Share this post


Link to post
Share on other sites

I love this module too!

I noticed that it doesn't seem to list Page References created inside Repeaters. That would be a nice addition.

-Brent

  • Like 1

Share this post


Link to post
Share on other sites

@bcartier: Sorry for the delay, I've been just catching up after being four weeks (almost) completely away from the computer.

You're right, fields inside repeaters were not handled at all. But now they are, as I've just pushed a new version of the module to GitHub. Seems to work ok. :)

  • Like 1

Share this post


Link to post
Share on other sites

@nik, great and essential module, using it all the time; Also learned from your code and was able to create some other modules that add their own tab.

One question though - is it possible to add the tab before the view link? Then when you click it, the buttons for save would be able to stay below the tab frame..

i guess it would somehow need to append the tab before the save button and view links...

Share this post


Link to post
Share on other sites

@Macrura

I think this might be covered by this issue on the repo. That linked page also shows how to fix the issue.

@netcarver - thanks, yes, this fixed it!

  • Like 1

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 MoritzLost
      Cacheable Placeholders
      This module allows you to have pieces of dynamic content inside cached output. This aims to solve the common problem of having a mostly cacheable site, but with pieces of dynamic output here and there.  Consider this simple example, where you want to output a custom greeting to the current user:
      <h1>Good morning, <?= ucfirst($user->name) ?></h1> This snippet means you can't use the template cache (at least for logged-in users), because each user has a different name. Even if 99% of your output is static, you can only cache the pieces that you know won't include this personal greeting. A more common example would be CSRF tokens for HTML forms - those need to be unique by definition, so you can't cache the form wholesale.
      This module solves this problem by introducing cacheable placeholders - small placeholder tokens that get replaced during every request. The replacement is done inside a Page::render hook so it runs during every request, even if the response is served from the template cache. So you can use something like this:
      <h1>Good morning, {{{greeting}}}</h1> Replacement tokens are defined with a callback function that produces the appropriate output and added to the module through a simple hook:
      // site/ready.php wire()->addHookAfter('CachePlaceholders::getTokens', function (HookEvent $e) { $tokens = $e->return; $tokens['greeting'] = [ 'callback' => function (array $tokenData) { return ucfirst(wire('user')->name); } ]; $e->return = $tokens; }); Tokens can also include parameters that are parsed and passed to the callback function. There are more fully annotated examples and step-by-step instructions in the README on Github!
      Features
      A simple and fast token parser that calls the appropriate callback and runs automatically. Tokens may include multiple named or positional parameters, as well as multi-value parameters. A manual mode that allows you to replace tokens in custom pieces of cached content (useful if you're using the $cache API). Some built-in tokens for common use-cases: CSRF-Tokens, replacing values from superglobals and producing random hexadecimal strings. The token format is completely customizable, all delimiters can be changed to avoid collisions with existing tag parsers or template languages. Links
      Github Repository & documentation Module directory If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
    • By MoritzLost
      This module allows you to integrate hCaptcha bot / spam protection into ProcessWire forms. hCaptcha is a great alternative to Google ReCaptcha, especially if you are in the EU and need to comply with privacy regulations.

      The development of this module is sponsored by schwarzdesign.
      The module is built as an Inputfield, allowing you to integrate it into any ProcessWire form you want. It's primarily intended for frontend forms and can be added to Form Builder forms for automatic spam protection. There's a step-by-step guide for adding the hCaptcha widget to Form Builder forms in the README, as well as instructions for API usage.
      Features
      Inputfield that displays an hCaptcha widget in ProcessWire forms. The inputfield verifies the hCaptcha response upon submission, and adds a field error if it is invalid. All hCaptcha configuration options for the widget (theme, display size etc) can be changed through the inputfield configuration, as well as programmatically. hCaptcha script options can be changed through a hook. Error messages can be translated through ProcessWire's site translations. hCaptcha secret keys and site-keys can be set for each individual inputfield or globally in your config.php. Error codes and failures are logged to help you find configuration errors. Please check the README for setup instructions.
      Links
      Github Repository and documentation InputfieldHCaptcha in the module directory (pending approval) Screenshots (configuration)

      Screenshots (hCaptcha widget)

       
       

       
    • By joshua
      This module is (yet another) way for implementing a cookie management solution.
      Of course there are several other possibilities:
      - https://processwire.com/talk/topic/22920-klaro-cookie-consent-manager/
      - https://github.com/webmanufaktur/CookieManagementBanner
      - https://github.com/johannesdachsel/cookiemonster
      - https://www.oiljs.org/
      - ... and so on ...
      In this module you can configure which kind of cookie categories you want to manage:

      You can also enable the support for respecting the Do-Not-Track (DNT) header to don't annoy users, who already decided for all their browsing experience.
      Currently there are four possible cookie groups:
      - Necessary (always enabled)
      - Statistics
      - Marketing
      - External Media
      All groups can be renamed, so feel free to use other cookie group names. I just haven't found a way to implement a "repeater like" field as configurable module field ...
      When you want to load specific scripts ( like Google Analytics, Google Maps, ...) only after the user's content to this specific category of cookies, just use the following script syntax:
      <script type="text/plain" data-type="text/javascript" data-category="statistics" data-src="/path/to/your/statistic/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="marketing" data-src="/path/to/your/mareketing/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="external_media" data-src="/path/to/your/external-media/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="marketing">console.log("Inline scripts are also working!");</script> The type has to be "optin" to get recognized by PrivacyWire, the data-attributes are giving hints, how the script shall be loaded, if the data-category is within the cookie consents of the user. These scripts are loaded asynchronously after the user made the decision.
      If you want to give the users the possibility to change their consent, you can use the following Textformatter:
      [[privacywire-choose-cookies]] It's planned to add also other Textformatters to opt-out of specific cookie groups or delete the whole consent cookie.
      You can also add a custom link to output the banner again with a link / button with following class:
      <a href="#" class="privacywire-show-options">Show Cookie Options</a> <button class="privacywire-show-options">Show Cookie Options</button> This module is still in development, but we already use it on several production websites.
      You find it here: PrivacyWire Git Repo
      Download as .zip
      I would love to hear your feedback 🙂
      CHANGELOG
      0.1.1 Debugging: fixed error during uninstall 0.1.0 Added new detection of async scripts for W3C Validation 0.0.6 CSS-Debugging for hiding unused buttons, added ProCache support for the JavaScript tag 0.0.5 Multi-language support included completely (also in TextFormatter). Added possibility to async load other assets (e.g. <img type="optin" data-category="marketing" data-src="https://via.placeholder.com/300x300">) 0.0.4 Added possibility to add an imprint link to the banner 0.0.3 Multi-language support for module config (still in development) 0.0.2 First release 0.0.1 Early development
    • By bernhard
      --- Please use RockFinder3 ---
    • By Craig
      I've been using Fathom Analytics for a while now and on a growing number of sites, so thought it was about time there was a PW module for it.
      WayFathomAnalytics
      WayFathomAnalytics is a group of modules which will allow you to view your Fathom Analytics dashboard in the PW admin panel and (optionally) automatically add and configure the tracking code on front-end pages.
      Links
      GitHub Readme & documentation Download Zip Modules directory Module settings screenshot What is Fathom Analytics?
      Fathom Analytics is a simple, privacy-focused website analytics tool for bloggers and businesses.

      Stop scrolling through pages of reports and collecting gobs of personal data about your visitors, both of which you probably don't need. Fathom is a simple and private website analytics platform that lets you focus on what's important: your business.
      Privacy focused Fast-loading dashboards, all data is on a single screen Easy to get what you need, no training required Unlimited email reports Private or public dashboard sharing Cookie notices not required (it doesn't use cookies or collect personal data) Displays: top content, top referrers, top goals and more
×
×
  • Create New...