Jump to content

Search the Community

Showing results for tags 'pagereference'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 7 results

  1. I’m working on a website with the following structure: |-- Academy (template = academy) | |-- Courses (template = courses) | | |-- Course 1 (template = course) | | |-- Course 2 (template = course) | | |-- Course [...] (template = course) | |-- Masters (template = courses) | | |-- Master 1 (template = course) | | |-- Master 2 (template = course) | | |-- Master [...] (template = course) | |-- Workshops (template = courses) | | |-- Workshop 1 (template = course) | | |-- Workshop 2 (template = course) | | |-- Workshop [...] (template = course) |-- Course Status (template = course_status) | |-- Status A (template = status) | |-- Status B (template = status) | |-- Status [...] (template = status) The course template includes a PageReference field called course_status, which connects to the pages under the “Course Status” section. Editor users cannot directly access “Course Status” pages but can create new statuses via the PageReference field (using the “Allow new pages to be created from field” feature). Objective I need to filter the status options by course groups. For example: Courses under “Courses” should share the same statuses. Courses under “Masters” should have a different set of statuses. If a new status is created under “Course 1,” it should automatically appear for all “Courses” but not for “Masters” or “Workshops.” Current Solution I save a reference to the parent page (e.g., “Courses”) within the newly created status page. This allows me to filter status options based on the parent group. Here’s how I implemented it: $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if ($event->object->hasField == 'course_status') { $page = $event->arguments('page'); $parent = $page->parent; $statusPages = $this->pages->get(1028)->children("related_courses={$parent->id}"); $event->return = $statusPages; } }); $wire->addHookAfter('InputfieldPage::processInputAddPages', function(HookEvent $event) { $field = $event->object; if ($field->hasField && $field->hasField->name === 'course_status') { $coursePage = $field->hasPage; if ($coursePage) { $parentPage = $coursePage->parent; if ($parentPage && $parentPage->template->name === 'courses') { $selectedStatusPage = $field->value; if ($selectedStatusPage && $selectedStatusPage->template->name === 'status') { $selectedStatusPage->of(false); if (!$selectedStatusPage->related_courses->has($parentPage)) { $selectedStatusPage->related_courses->add($parentPage); $selectedStatusPage->save(); } } } } } }); The Issue The setup works well except in this scenario: 1. I create a new status (e.g., “Open”) under “Course 1.” It appears for all “Courses” as expected but not for “Masters,” which is correct. 2. If I try to create a status called “Open” under “Master 1”: A new page is not created (presumably because the title “Open” already exists). The “Open” status becomes available but isn’t automatically selected. I have to manually select it and save again to finalize the selection. Questions How can I ensure that the existing status is automatically selected in this case? Is there a better, more efficient way to manage the entire status setup? I’m open to restructuring if it leads to a smarter solution. Thanks in advance for your help!
  2. While using the page reference from vanilla processwire with Rock page builder, I have a hard time finding the right syntax. $link2 = $pages->find("page_reference_01=$page, sort=parent.sort, sort=sort"); Normally, I would use a line like this. But this does not quite work, as the page references are on a page in a block(on another page), while using this, I sometimes could target $block instead of $page, but it does not work this time. What are the right way to find a page reference within an other page within a block. $link2 = $pages->blocks->find("page_reference_01=$page, sort=parent.sort, sort=sort");
  3. Hello, I'm trying to create a page via api and populate values to it. I can populate everything except user pages to a page reference array. Code: $dataUsers = $data->project->users; foreach($dataUsers as $dataUser) { $newProject->projectUsers->add(wire()->pages->find('template=user, id=' . $dataUser->id)); } I'm receiving my data via JSON. Is there something I'm missing? Thanks for help
  4. Is it possible to pre-select values in the Page Reference field? I am currently using 'Page List Select Multiple' that allows my users to pick from a large number of FAQ's. Can I pre-populate this field with a default 5 answers (Pages)? Allowing the user to add/remove from this default selection.
  5. [EDIT]: After sitting down and planning out my site according to the ragged hierarchy information, I settled on the following schematics. /$world/$template/$content_of_template_type/... for my pretty URLs /roster/$character for my characters a generic Repeater field with depth on most content types for custom positions for child pages to connect to instead of it directly a few Repeater fields on each content that have (PageReference[1], other fields) to establish associations A few FieldsetGroups to help me manage the fields that I needed to copy across a bunch of content types. Kept the original post below for context and tagged the OP for searchability. --- Hi everyone! I'm working on a personalized worldbuilding wiki to host my art and story stuff. Right now my site architecture looks like... /$world/cosmology/$cosmology /$world/locations/$location /$world/factions/$faction /$world/history/$history /$world/species/$species /roster/$character So far the layout works, but there's one problem. I need to make sub-sections for an organization. Organizations can appear under cosmology, locations, and factions. Sounds straightforward until... I run into the problem of figuring out how to represent subfactions. Key factors in this are... Characters should be able to be part of multiple organizations Characters should have an explicit role assigned to their membership. Character pages should be able to query the organization pages to display their ranks across organizations. Editing an organization's hierarchical layout should be visible while editing the root organization page. From what I've read of the ProcessWire documentation, the best use case for each way of representing the organization's subsections are... Child Pages:: Works best for menu presentation and dedicated editing. PageTables:: Works if you want control over where to place the PageTable fields, but requires opening a modal for the pages you want to edit. It's also kind of like normal pages. Repeaters:: Works great for inline editing and easy control over hierarchy, but the page urls become obscure. Sections in the body field:: Works for copypasting from my note files. But it doesn't expose relationships for easy querying. It looks like my best case for this is child pages since it allows displaying suborganization in the URL easily. But also I lose out on quickly reordering and editing the child pages. Any advice for people running into similar use cases?
  6. Hello, I have a Page Reference by template radio button field to promote a certain page (only two options), but I'd like to target the page that isn't selected. This would be used dynamically throughout the site. Does anyone know how I could accomplish this? Would I use something like remove() or not()?
  7. Hi Folks, Encountered strange problem re: PageReference + MapMarker. The PageReference is being used for creating "tags" ala @renobird from this comment here: ( thx renobird! ) I then have a template with the PageReference on it, then below that a simple and standard MapMarker. If i set the Page Reference to "Allow New Pages Created", it's great, new tags can be added in. But when you then tab into the MapMarker and set the location all appears fine until you either Save Page or Publish. At that point, the page is saved, the new tags are added correctly, but No Location is saved in the Map Marker. If I set the Page Reference to NOT "Allow New Pages Created", the MapMarker location is saved perfectly well. So does anyone know if something weird happens in the "Save", that successfully adds in the new tags, but looses what was put into the MapMarker location ? Thx!
×
×
  • Create New...