Jump to content

PageLister and PageFieldType is tedious on duplicate titles


mn-martin
 Share

Recommended Posts

Hello,

it's very hard for me to describe the actual problem so I've attached two screenshots that contain all the required information.

Basicly I'm trying to manipulate the page title that is rendered to the select field options within the page lister when setting up a filter using a  PageField. (It's tedious to select the page you really want on duplicate titles)

I can't find any solution to this problem. It doesnt seem to be as simple as hooking onto a render or textformat method.

(Many attempts, no success ...)

Please, can anyone help me out on this one?

post-4153-0-44024800-1455808903_thumb.pn

post-4153-0-23293600-1455808905_thumb.pn

Link to comment
Share on other sites

hi,

can you add a second filter for the parent pages?

Categories has .....

Categories.parent has ....

this would reduce the confusion with the similar page titles

cheers,

Tom

Hello Tom,

thank you for that hint. It may work in the most cases. Unfortunately in my special field setup it didn't work. Anyways I've came up with another solution:

// Admin > Setup > Fields > Custom PHP code to find selectable pages

$categories = $pages->find('has_parent="/categories/", template="category"');

foreach ($categories as &$category) { 
    $breadcrumbs = wire('helper')->buildBreadcrumbList($category);
    $category->title = join(' / ', $breadcrumbs);
}

return $categories;

Since I don't execute $category->save() that should be perfectly fine there and it seems to work like a charm without any side effects.

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