Jump to content

PageReferencesTab


nik
 Share

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
Link to comment
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.

Link to comment
Share on other sites

  • 2 weeks later...

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
Link to comment
Share on other sites

  • 1 month later...

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
Link to comment
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
Link to comment
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.

Link to comment
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
Link to comment
Share on other sites

  • 2 months later...
  • 2 weeks later...

@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
Link to comment
Share on other sites

  • 1 year later...

@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...

Link to comment
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
 Share

×
×
  • Create New...