Posted 17 March 2012 - 03:35 PM
I used the Page Fieldtype (thanks Diogo and others from my first thread) to link pages to each other and it works like a charm. The thing is I would to see the relation two ways in the backend.
Example: I link page A to page B1 and page B2. When I edit page A in the backend I see B1 and B2. But I'd like to see page A when I edit page B1 (or B2).
I tried to put the same field in the other template, but that (perhaps obviously) did not work.
What kind of field do I need to put in the template? Is this possible?
Posted 17 March 2012 - 04:04 PM
For example, on one site I link news to companies, so the Pagefield for the company is available in the news template (call that field related_company) and I can therefore show some company info with that news article.
On the company page via the company template, I can still pull news articles for that company (the reverse of the above) by using something like $news = $pages->find('template=news, related_company=$page');
I would say that unless you have a real need to do this, try not to over complicate it.
Of course, your scenario could be very different
Posted 17 March 2012 - 05:50 PM
I got an employee A who is linked to a service. Also employee B is linked to that service. On the service page (in the administration part) I thought it would be handy to see which employees are linked. Even to de-link them. If you have any thoughts if this sounds too much I would be glad to hear that
Posted 18 March 2012 - 01:15 AM
Posted 18 March 2012 - 04:34 AM
The first time I thought about it, back when I was very new to PW, I thought that it should save the relationships both ways. Obviously to de-link the pages this makes it a bit more complicated, plus adds unnecessary clutter to the database (you're saving the relationship twice).
Your module idea sounds good and I don't think it would be much more work on top of the "view relationships" to have a button that removes the relationship, so you can do it from either end.
Having said "I don't think it would be much more work" I don't have time to look at it myself, but I agree it would be an interesting one to look at for the future. Could even be a useful core addition.
I think the only concern I have is to keep it from being confusing for the user, as if they can see page relationships but can't add relationships this might become confusing. Again, you could theoretically add functionality to create more relationships from such a module, but then you're really blurring the lines around which page the data is actually stored against.
I like to over-complicate things - maybe just viewing the relationships would be fine
Posted 18 March 2012 - 06:58 AM
Posted 18 March 2012 - 08:43 AM
If the page isn't part of the front-end site, then I'll remove view access from its template. Or if it is part of the front-end, but I don't want to show the relations, then this:
if($page->editable()) echo $pages->find("field1=$page")->render();
Though I almost always integrate these relation-revealing pages into the site structure, as it's rare that this information doesn't have some value to the site's users too. This is an example of one that locates all pages referencing it in a field called 'country':
Posted 02 March 2013 - 07:05 AM
Just wanted to ask: are there any new developments regarding arjen’s request or does one still have to use the »front-end approach«? Thanks.
This feature is not currently on the roadmap, but I would guess someone will develop this as a module at some point. When it comes to core stuff, we really try and focus on stuff that would be used most of the time, and leave occasional use things mostly to modules.
Posted 02 March 2013 - 07:47 AM
I have created a sample module that does mapping two page fields against each others
I also have a rough module that adds links to the pages linked after saving, but it's not something I can share.
But looks like it's not what you actually ask for, but anyway all is possible.
Posted 07 March 2013 - 02:56 PM
@arjen, @isellsoap: I'm not quite sure if it became what you were thinking of, but this conversation was the inspiration behind this: http://processwire.c...ereferencestab/
At least it's something you could use as a base for something more if it's only half way there at the moment.
Also tagged with one or more of these keywords: relations, page fieldtype
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users