Jump to content

Search the Community

Showing results for tags 'pagefield'.

  • 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

  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. Hi folks, I have a simple PageField set up, which is being used in this instance as a 'Related Articles' area; they can choose (Multiple Pages) which news articles are related then it does something nice front end. The only issue I have is that I'd like to limit the number of articles they can choose (only allowing three, for example) much like you would have in a File field or Image field (Maximum files allowed). Any thoughts?
  3. Hi folks, I use the Page field quite often to cross reference data on the sites that I build and they are super useful, but I have a question regarding doing the same thing but with a repeater field? I know a lot of you know might think that perhaps I am using the repeater field wrongly and that the data should in fact be pages but I believe in this case that the repeater field is the best option. I have a Publications section on my site, which include image and title only, for each. I had thought about making each Publication a 'page' but then all you have on each page to edit is an image and thought this was maybe a bit clunky to do and a repeater would be better? So, if I make Publications a repeater... can I grab a specific 'field' from the repeater in a Page-like field? So, on another section, say Projects, I would be able to link a specific Publication to a Project via a dropdown field. You know? Let me know if you think there's a better way of doing this... it might be that if I ever need to cross reference another piece of data (an entry in the CMS) then it needs to be part of a 'page' and then easily selectable via a Page Field. Thanks! R
  4. Hi folks, I have a repeater set up on a 'fabrics' page. When you add a fabric, you then add an image and a colour (per row on a repeater); the colour field is a pageField which lists out all the colours from the Colours section. See screenshot for an example. Across the site, where 'related fabrics' come into play, the client will choose, via a pageField, all the relevant fabrics and it'll take the first row of the repeater (image and assigning colour) and display it. See second screenshot as an example. This is all good and works BUT there is one section of the site 'In-Situ' where the client would have to choose a specific colour from a fabric (and not just the fabric). As the image/colour combos are set up as a repeater (which are added as pages in the CMS under 'Admin > Repeaters' (which is amazing) I can simply tell a pageField, using a custom selector, to show each 'row' from across the site (which would return all the images and colour options for each fabric). template=repeater_collections_detail_images, include=hidden, sort=name This works a treat. I can then use the custom page label format which would return the parent title of the page it's on and then the title of the colour chosen. {parent.title} – {collections_detail_image_colour.title} I have one issue, however. The parent.title isn't user-friendly and is rather the canonical title of the page, not the actual title of the page, so looks more like a name than a title. See the third and fourth screenshot as an example. The only thing I can think of is that these repeaters and their rows are on these specific fabric pages, right? So is there a way for the custom page label format to return the title of THAT page and not the repeater page? See my final screenshot for what I mean. The repeater has a path, for example, .../for-page-1080/ and the page 1080 that it is referring to is the page of the title I am trying to get. Any ideas? I realise this is a little long-winded but any help or advice would be appreciated.
  5. Hi there, I have a problem constructing a selector that finds all pages that refer to pages with a specific template. I have pages using an event template and I want to show events based on a specific context. In this example I want to filter the results and only show event pages that relate to a specific template (exhibitions) in their page field related_pages. What I tried: $events = $pages->find("template=event, related_pages.template.name=exhibition"); Unfortunately it does not work (0 results). Same with this: $events = $pages->find("template=event, related_pages=[template.name=exhibition]"); At the moment I am helping myself with the following lines, but I have a strong feeling that there is a more efficient solution: $events = $pages->find("template=event"); foreach($events as $event){ if(!count($event->related_pages->find("template=exhibition"))){ $events->remove($event); } } I really hope that one of you can help me out. Thanks in advance! Flo
  6. Hello, I'm struggling with this : a 'group' field of 'Page' type. The parent of selectable pages is '/groups', the template is 'group', and a member can create some groups in the /groups tree. I would like this user to see only the groups he or she has created so in my 'Find selector' in the backend, I would like to use : template=group, created_users_id=$user->id But that doesn't seem to work... I still get the list of all available groups in the /groups tree. Any idea ? I had a feeling I had already seen that before (something like $user->id must be replaced by users_id or something, but I can't find anything in the Forums... and all my tests keep failing...
  7. So, I really don't know where to begin with this. I have the thought in my head (the basics), but not really sure how to set it up. The desired effect: The homepage is set up with a foreach loop that outputs all the child pages (basically just a bunch of pages with pdfs, docs etc stored in a file field). When A user is actually logged in, they can "star" an item or drag and drop (using Dragula) the page to a sidebar. Also, they would be able to reorder the pages in the sidebar. The question(s): I guess I have multiple questions regarding how to achieve this. Would it be best to create a page field in the user template to save the page(s)? How would you actually save the page state (sidebar output, reordering, etc) once the drag and drop has been used? Thanks in advance for any help! A lot of this was just what was in my head, so it might not make full sense. However, I will update this if I can actually wrap my head around everything.
  8. I'm wondering about creating a query that involves looking across two different parent page trees. One parent is for blog posts and it has each post under that. Another parent is used for categories and subcategories for the blog. Then in the blogs there is a page field that can reference the categories. This is all pretty normal setup so far. I created a navigation that lists the current category and its children, but I want to not show categories that have no posts. For some reason I'm drawing a blank. So let's say a user clicks category1, and it shows a blog listing for that category. I query for all the child categories of the current one. Now I want to exclude any categories where NO blogs exist that make reference to the category (an unused category). How do I do this in a way that is performant? I don't want to have to query the blogs tree over and over to test for the presence of each category in the list! Here is the tree: blogs - article1 [pagefieldcat = "cat1"] - article2 [pagefieldcat = ""] categories - cat1 - cat2 Now when I get all children of categories, I want to exclude cat2 since it's not referenced from any blogs. Can I do this without having to loop and query every category against every blog one by one? Thanks
  9. Hello everyone, i guess my php knowledge is not good enough to find a solution for the following problem: I'm building a website where i have projects. Each project has tags like "webdesign, responsive, cms, print, flyer" etc. At the end of a project i want to recommend other projects, which have similar tags. I want to limit the recommendations to three other projects sorted by the hightest amount of same tags. This is how far i got: I'm using <?php $interessantes = $pages->find("tags=$page->tags, id!=$page->id"); ?> to find other projects with the same tags, excluding the page i'm already on. Then i'm using three foreach-functions to go through the projects i found, the tags they have and compare them with the tags of the project i'm looking at. If i have two identical tags, i count up a variable. <?php // Projects i have found foreach($interessantes as $interessant): $i = 0; // Tags of the projects i have found foreach($interessant->tags as $tag): // Tags of the project i'm looking at foreach($page->tags as $tagreferenz): if($tag == $tagreferenz): $i++; endif; endforeach; endforeach; endforeach; ?> You can see what it looks like in the screenshot with a bit of HTML. I marked the tags of the current project green and the identical tags of other projects red with the amount of hits below. So in this example i would want to have three projects with three similar tags and get rid of those with only two and one. I guess i have to put my pages into an array (with the number of hits?), sort them and echo them with "limit=3"? Unfortunately i have no idea how to do this. You probably have an even better/shorter solution. Links to other topics are welcome to and i'll try to get my head around it. If you need further explanation, i'll try my best. Best regards
  10. For one of my projects, I'm currently building a small events calendar in ProcessWire. One requirement is that an event may have an unlimited number of associated dates. I tried two approaches, however each approach come with a difficulty: 1) One page per event with a repeater that holds the dates. Page: Event 1 Text fields for shared event info Repeater with a date field (e.g. Jan 1, Feb 1, ...) Page: Event 2 Text fields for shared event info Repeater with a date field (e.g. Jan 10, Jan 11., ...) Problem: How can I get a chronological list with all events (dates + shared info) that is sorted like that: Jan 1, Event 1 info Jan 10, Event 2 info Jan 11, Event 2 info Feb 1, Event 1 info ... I know how to access repeaters, however all I got so far is a list structured like that: Event 1 info Jan 1 Feb 1 Event 2 info Jan 10 Jan 11 2) A page with a page reference field from which the backend user shall be able to directly create child pages for each associated date. Problem: What selector string do I need in the page reference setup, to make sure the new page is always created as child of the current page (no matter where that page lives in the backend structure)? Or is this only possible with custom PHP code in ready.php? Would you consider one of those approaches a good strategy? If so, do you have any solution to my problems? If not, is there a better way?
  11. I'm trying to sort pages based on their parent's fields, which are page references. For instance: $someOrders = $pages->find("template=order, sort=parent.customer.id"); Here, order's parent has a template called 'orderslip' that has multiple 'order' children. Orderslip contains a page field called customer, and I want to sort based on the parent's customer's id. But i can't make it work. It throws out an exception: Error: Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'customer' in 'order clause' (in /srv/rewwwards/wire/core/PageFinder.php line 410) I'm sure customer page field exists and it works everywhere else. It's just that this time, I'm trying to sort it from a page's 'parent' selector. Is it even possible do this? As always, any help is greatly appreciated. Thanks.
  12. Hi everyone, this is more a note than a question but I also wanted to know if it is wanted to be like that, and I didn't find any Info on this. I had a structure like that: my site has a user-profile page and a PW user. The user has a page field to link it to its profile page. So far so good, but to get some information from the PW user I set a page field into the profile page, so both pages are bound by two lines (profile<=>user). Each line goes in only one direction. What happened after is this: the server run out of memory (allocation?). Seems like the page input fields run in circles. The page was still shown, but broken, with the error at the bottom. The fix was easy: just put one page field into the PW user, link that with the profile and do a $users->find("page_field=$page->id") in the template of the site. Easier done could be to use the $page->createdUser profile value, but that makes it a little more complicated to change at creating the user and profile site. Will do that later on. Many ways to go, I like that the most on PW As I understand this can happen to any pages, so be warned to not combine pages like this. There are better ways. So: is this a wanted logic? Two pages can loop into each other? Are there any security notes on something like this, maybe on the docs? Or something like small notes to DO NOT do something like this or be warned somehow? Thanks!
  13. Hi I'm now understanding the basic of PW but for this one, I have no idea where to begin. I have 2 pages : publication and member. I want to add publications (automatically as I created them) to its member. Since I have hundred of publications, I want to create them using csv import. I used a specialised software to export them in the way I want. The format would be Name LastName1, Name LastName2 (2016) Title. Journal. Vol:Number. Url. I have variable numbers of authors by publication. My member's template have the title containing "Name LastName" and have a pageField "publi". How I can achieve that? I read in the forums I could assign page to a field via hooks. But I'm not sure what I should do. Also a more design question, do I should create all authors as unique fields? How I can create the good number of those fields? Or can I just create 1 author field in publi's template and search inside this value? Also for the others fields, do I should create them individually if I want to output this specific markup (italic, bold)? Hope it is clear... Thanks Mel
  14. Hello everyone, I'm currently linking several templates to each other thanks to the Page Field. Whenever I link a Page (A) to another Page (B), I can only see/edit/remove this relationship at Page A, but not on Page B. Is it possible to also create/see/edit/remove this relationship from Page B? Thus, having a bidirectional Page Field? Hopefully this is possible, it would be of major help in the administation workflow. Greetings, Charlie
  15. Hello, I use a page field to link members to cities. But a city must be associated just with 1 member, no more. And of course, in the admin, when I go to the member page, the page field "cities" lists all values even if they are already used. So the question is " In the admin, can we filter values of a page field with a rule (a custom function?) " ? In my case, if the value is already linked to a member. Thanks a lot for your help! Chris
  16. I have a page field calles select_multi_dates. I set a php specific selector like this $currentActivity = $page->parent; return $currentActivity->activity_create_date; It shoud give me all pages from the activity_create_date pagetable, what it does well but the problem is that the label is shown as timestamp. And here is the configuration of the page field: What I'm missing?
  17. I have a template called "activity" with two pagetable fields. Fields: activity_create_cast activity_create_date activity_create_cast: uses "cast" template for creating castpages. the cast template contains a pagefield called select_multi_dates. activity_create_date: uses "date" template for creating datepages. the date template contains a pagefield called select_activity. Now what i want is create a cast with activity_create_cast and I want that the selection of the select_multi_dates pagefield should be the pages wich i created before with the activity_create_date. How can I achieve this under the select_multi_dates pagefield with a PHP-Selector? I know its complicated PHP-Selector. Hope you can help me. Thanks for your attention. Nukro
  18. Hello Processwire Community Lets say i have a pagefield called select_organiser. The select_organiser pagefield is assigned to the user template and to the location template. Every User can create a location where he can set a organiser with the select_organiser pagefield. The Superuser can also create locations and he can assign a organisation to a user. No what i want is that the pagefield should check if the current user is a superuser, when yes he get a selection of all organiser pages. But when the current user is not a superuser he should get only a selection/select of the organiser that the Superuser has assigned to him. for example: organiser pages: organiser-example-1 organiser-example-2 organiser-example-3 organiser-example-4 ... users: test-user-1 test-user-2 ... Lets say I am the Superuser and i assign organiser-example-1 to the user test-user-1. Use Case: Create Location as Superuser I have a select with the selection: (organiser-example-1, organiser-example-2, organiser-example-3, organiser-example-4 ...) Use Case: Create Location as test-user-1 I have a select only with the selection: (organiser-example-1). This means I can only create Locations with the organiser: organsier-example-1. I hope you understand what i want to say/ask.
  19. I'm trying to achieve a specific selection for a pagefield for specific users. My pagefield should detect: If the current user is a superuser return all address-pages and when it's not a superuser, return all address-pages which the current user has created. It works fine for the superuser but i have no selection in all the other users. if(wire('user')->isSuperuser()){ return $pages->find("template=address"); } else{ return $pages->find("template=address, created_users_id=wire('user')->id"); }
  20. I have the problem that i cant render a fredi link to a page which i choosed from a pagefield from a user. i have a user called "test-user". This "test-user" template has a pagefield called select_organiser which contains all the organiserpages. My approach: $organiser = $user->select_organiser; <li>'.$fredi->setText("<i class='fa fa-pencil'></i> Veranstalter bearbeiten")->renderAll($organiser).'</li> What I am doing wrong?
  21. I have a bunch of child pages added to a parent section called 'Projects'. These are all being looped out on an overview; for example: <?php $projects = $pages->find('template=project-detail, sort=sort'); ?> <?php foreach ($projects as $project) : ?> These pages will become quite long overtime, but I want to add a 'featured' option to them so they add a class to their element if they are 'featured'. Normally I would just add a tickbox so if it's ticked, it adds the class etc. However, as there are going to be so many pages, looking through them all and maintaining this (as the 'featured' option will change often) will get a bit messy. So, I've created a 'Page field' for the overview, so you can choose which pages you want as 'featured' and remove them easily. However, I'm having an issue working out how I can tell the child page that it has been 'chosen' to be featured, if you see what I mean? How can I, within the $projects loop, cross reference it with the 'featured' page field on the overview, and if they match, add a class? For example <?php $featured = $pages->get('template=home')->featured_items; ?> // Getting an array of the featured items <?php $projects = $pages->find('template=project-detail, sort=sort'); ?> <?php foreach ($projects as $project) : ?> <div class="item <?php if ( $featured->id == $project->id) : ?>featured<?php endif; ?>"></div> // Checking if the featured id contains project->id <?php endforeach; ?> I know the above isn't right, but you get the idea. Can you help at all?
  22. Hi. I need to compare two pagefields. I tried this: $page->locations->has($user->locations) But this doesn't work. I need to compare them and find out if the $page->locations has one or more of the same locations as the $user->locations. Hope it makes sense.
  23. Hi folks, I am using the PageField to find selectable pages and I'm using the 'custom PHP code' field to find my pages. However, the following isn't bringing back any pages: $pages->find('parent=/tags/' . $page->parent->name . '/'); I have tested this code on the page template, and it returns the correct pages but entering this into the custom PHP field returns an empty dropdown field. Any thoughts?
  24. Hi folks, I have a simple Page field setup to act as a tag system. This has worked for me, but for some reason it's not working now and I can't find out why. I can select previously added 'Pages' here, but cannot add new ones (comes up with a little warning symbol (see attached)). Any way I can check through to see what I have changed to affect this? Debug mode? What should I be looking for? I have tried to test it alongside another project with a similar setup that still works but all seems to be the same? Thanks guys, R
  25. i've searched this topic via google but didn't found anything... question is simple in a pagefield i get some entries (autocomplete, or multipageselect...) - is it possible to get a edit link on these pages link in the admin edit templatefield lists? i know there is the id given and with that i could code some js to get a link from that....but first ask if there was a proper methode or solution ready to use? a little screen for example: regards mr-fan
×
×
  • Create New...