Jump to content

Recommended Posts

Posted

So I started on the project I spoke of earlier and already got most things signed off. With the search function and some video's I was able to build the site. I got a couple of things to work on like a contactform. I guess that shouldn't be to hard. PW seems to be very intuitive and it feels very mature and well thought of.

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?

Thanks!

  • Like 1
Posted

My first question is why would you need to do that (I originally wanted to do the same thing)? You can already use selectors via the API in templates to find pages in the other direction.

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 :)

  • Like 1
Posted

Thanks! That's exactly how I did it in both templates. I thought for the user it would be nice to see in the administration part if a page is linked to another. Therefor the user won't have to look in the other page or on the actual website itself to determine wether any pages are linked.

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

  • Like 1
Posted

Currently there is no such a feature, but I agree that it would be a useful feature to have. It shouldn't be too difficult module to build. Maybe a fieldtype that just shows all relations for that page and where they are defined.

  • Like 2
Posted

Thanks for clarifying Apeisa. It isn't that big of a feature, but it would be nice.

Posted

I think you're on the right track Antti.

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 :D

  • Like 2
Posted

It depends on how you present the information. If you can see the relations, but don't have any clickable objects, let's say, just a diagram, I think it should be clear enough. I haven't got any clue on how to build this, but after this project I haven't got any new one yet. So it might be worth exploring this further.

  • Like 1
Posted

A pre-made module for this on the admin wouldn't know what field(s) might be referencing the $page, so it would need to locate all the Page fieldtypes, and perform a check on all of them: "field1|field2|field3=$page". I prefer to view these kind of relations on the front-end of my site (where I can give them a known field context), so my template for the pages in the relation will usually have something like this:

echo $pages->find("field1=$page")->render();

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':

http://www.tripsite.com/countries/croatia/

  • Like 2
Posted

Thanks Ryan, for now I will look up the relation in the front-end. It does make sense indeed because you can see the context.

  • 11 months later...
Posted

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.

  • Like 1
Posted
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.

  • Like 1
Posted

I have created a sample module that does mapping two page fields against each others

As per http://processwire.com/talk/topic/2384-change-the-value-of-one-field-by-editing-another-one-possible/

https://gist.github.com/somatonic/4335296

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.

  • Like 1
  • 4 years later...
Posted

Hello

This conversation is some years old. Is there any update to  this?

As an example in the skyscraper demo, I would not only like to select an architect on the building page

http://demo.processwire.com/admin/page/edit/?id=4195

...but also a building on the architect page.

http://demo.processwire.com/admin/page/edit/?id=5726

These should be in sync or ideally use the same data source.

Does such a solution exist now?

Thank you.

  • Like 1
Posted

Works a treat. :rolleyes:

Just the fact,  that the two tables in the database are redundant, is a bit sub optimal.

I guess it is because of how the page field works?

But I can live with that.

Thank you.

  • Like 3

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
×
×
  • Create New...