-
Posts
812 -
Joined
-
Last visited
Everything posted by a-ok
-
Getting the page title a repeater field is on from a pageField
a-ok replied to a-ok's topic in General Support
$pages->addHookAfter('Pages::saveReady', function($event) { $page = $event->arguments(0); $repeater = $page->collections_detail_images; foreach ($repeater as $row) { $row->of(false); $row->collections_detail_image_page_title = $page->title; $row->save(); } }); This is what worked. -
Getting the page title a repeater field is on from a pageField
a-ok replied to a-ok's topic in General Support
Only thing I'm struggling with is trying to add a hook to a repeater set the value of a field per repeater row. I thought this would've worked $pages->addHookAfter('Pages::saveReady', function($event) { $page = $event->arguments('page'); $repeater = $page->collections_detail_images; foreach ($repeater as $row) { //$page->message($row); $row->collections_detail_image_page_title = 'TEST'; } }); -
Getting the page title a repeater field is on from a pageField
a-ok replied to a-ok's topic in General Support
I think what I could do is include a hidden field in the repeater and write a addHookAfter to fill this hidden field with the page title on save, then just use that field? Seems a bit odd? But maybe not? -
Getting the page title a repeater field is on from a pageField
a-ok replied to a-ok's topic in General Support
Just an update. If I put {parent.path} – {collections_detail_image_colour.title} as the custom page label format then it shows the 'for-page...' -
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.
-
Yes that worked, adrian. Thanks and sorry for overlooking that section.
-
I had to import a table from an old CMS; I just wrote a mySQL query to do it... but maybe I could've used the API?
-
I've had to add a new field to the DB via mySQL (and not via the CMS) under the table 'field_archive_text'; only issue is now I need it to appear as a field (which would then be populated by the data) in the CMS to add to a template but alas when I try to make the field it states it already exists. Is there a way to force re-check the tables from the DB and if a new one exists to add it as a field? Anyone else had a similar issue?
-
Return pages from, in-between and exclude specific year/years
a-ok posted a topic in General Support
I'm wanting to return pages of the current year only. I have a date field set up 'article_detail_date'; but unsure how to write this into the pages selector. $pages->find("parent=articles, sort=article_detail_date"); I'm also curious to know whether you can do it between two years; and also exclude a specific year. My thinking would be... $current_year = date('Y'); $article_year = article_detail_date('Y'); $pages->find("parent=articles, sort=article_detail_date, article_year=current_year"); Only thing is '$article_year' isn't working as it's before the loop... Any ideas? Thanks! -
How to detect image width, and if smaller than x, display at original size?
a-ok replied to kathep's topic in Getting Started
Thanks, LostKobrakai. Just seems unnecessary to include those images in the selector to loop but then disregard them... why not just not include them in the selector. -
How to detect image width, and if smaller than x, display at original size?
a-ok replied to kathep's topic in Getting Started
Sorry to bring an old topic up but is this possible as a pages selector? $pages->get('parent=/article-overview/, limit=1, sort=random, article_detail_featured_image.count=1, article_detail_featured_image.width>800'); -
Of course. So the fields are named: article_overview_flexible_layout_link (PageField) article_overview_flexible_layout_type (Option 1) article_overview_flexible_layout_width (Option 2) The selectable options for article_overview_flexible_layout_type (Option 1) are: 1=Side by side (image on right) 2=Side by side (image on left) 3=Full image (text on top) 4=Small And this is set to a required field with the default option: 1=Side by side (image on right)The selectable options for article_overview_flexible_layout_width (Option 2) are: 1=100% 2=50% And this is set to a required field with the default option: 1=100%And this is the field (article_overview_flexible_layout_width (Option 2)) that has the 'Show this field only if' condition of: article_overview_flexible_layout_type=3
-
I think I've found a bug. Unless I've done this incorrectly. I have a repeater set up that has three fields; a PageField and two Options fields. When you add a new repeater row; you choose your 'page' (PageField) then you choose a 'type' (first Option field) which has four options. I have the second Option field ('width') set up so it only shows if you select the third option from the first Option field. The second Option field has two options (100% and 50% with it being a required field and the default being 100%). If I remove the 'show if' functionality on the second Option field ('width') it shows/works fine but if I add this functionality back in; even though the action of showing/hiding work... when I click 'Save' it doesn't remember the option I choose and it defaults back to 100%. Any thoughts?
-
Field visibility conditions (only show if parent is...)
a-ok replied to a-ok's topic in Getting Started
I believe I have this working: https://processwire.com/talk/topic/9406-inputfield-dependencies-hide-field-by-path/?p=121319 -
I believe this is working; the field 'article_detail_parent' will be hidden and checked if the parent_id of the page I am editing matches that. Then I can use the ShowIf field to state if article_detail_parent=1 then only show X $pages->addHookAfter('Pages::saveReady', function($event) { $page = $event->arguments('page'); if ($page->parent_id == 1043) { $page->article_detail_parent = 1; } }); Only issue is that setting this field to hidden removes it (rather than visibility:hidden; which I'm assuming would retain the value?) Only way I found to do this was to include a separate stylesheet in admin.php and set the visibility:hidden and height:0. This all seems way over the top to simply not show a field based on the parent?
- 10 replies
-
- Inputfield Dependencies
- path
-
(and 1 more)
Tagged with:
-
Can you expand on this answer at all? Thanks!
- 10 replies
-
- Inputfield Dependencies
- path
-
(and 1 more)
Tagged with:
-
Field visibility conditions (only show if parent is...)
a-ok replied to a-ok's topic in Getting Started
Thanks all. I'm wondering if I can use a PageField and set the Selectable Pages (using the PHP options) to the parent page? return $page->rootParent; return $page->parent; If this then returned the parent as the default page option then couldn't I then use the following for the Show if? pagefield=123 -
Field visibility conditions (only show if parent is...)
a-ok replied to a-ok's topic in Getting Started
Thanks for the reply. Yes, this is what I am using but it doesn't allow for a page field, it seems. Only a field value. -
I'm unsure if this has been answered, or is perhaps in production, but it's not possible to only show a field if it's parent is a certain ID, right? It's field=value not page=value, right? Only reason I ask is more often than not I use the same template/fields for certain pages but sometimes the fields are specific to the page parent being added to so would be nice to have the option. The only way round this is to create a Page field and have all the fields hidden until they select a 'parent' from the Page field. For example, 'Which fields would you like to use?'.
-
Multi-Language Support relevant to specific sections
a-ok replied to a-ok's topic in General Support
Thanks for this. The 'alternative field approach' is perfect. However, I'm just a bit stuck with having languages set up only specific to certain sections and now the whole site. -
Hi folks, I have a site set up for a festival of events over the next 5 years. Each year (page with children) in the site is in a different location and we want to use the Multi-Language Support to toggle between the native language of the location and English. I have set up the Multi-Language Support stuff fine but the only issue is that it's applying it to the whole site whereas I only need to use specific languages in specific sections. For example, for a Portuguese section a URL might be http://www.domain.com/pt/designing-respect/home/ whereas I need something like http://www.domain.com/designing-respect/pt/home/ instead and on another section for a Chinese section a URL might be http://www.domain.com/designing-politics/cn/home/ so the language support is being applied to the section rather than all of them to the same whole site. This is also the case with using multi-language title fields; it's adding all the options to all the pages whereas I need them only on the relevant sections (so within the Chinese section you'd get the English title field and the Chinese title field; not all the language title fields). Any ideas?
-
This is what I came up with... after much trial and error: <?php $geojson = array( 'type' => 'FeatureCollection', 'features' => array() ); $programmes = $pages->find('parent=programme, sort=sort'); foreach ($programmes as $programme) { $marker = array( 'type' => 'Feature', 'properties' => array( 'title' => $programme->title, 'url' => $programme->url, 'summary' => $programme->programme_summary, 'image' => $programme->programme_venue_image->url ), 'geometry' => array( 'type' => 'Point', 'coordinates' => array( $programme->programme_location->lng, $programme->programme_location->lat ) ) ); array_push($geojson['features'], $marker); } $programme_json = json_encode($geojson); ?>
-
Yeah I tried that too, but it threw back a JS error saying unexpected token } $programme_json = substr($programme_json, 1, -1);
-
What's even weirder is that if I add the square brackets [ ] to $marker = array( effectively making it $marker[] = array( then it returns all the items BUT it has the square brackets on it. I'm so deep down the rabbit hole...
-
I have come up with the following, which works in terms of formatting BUT it's only returning one item and not three (three children pages to the parent 'programme')? $geojson = array( 'type' => 'FeatureCollection', 'features' => array()); $programmes = $pages->find('parent=programme, sort=sort'); foreach ($programmes as $programme) { $marker = array( 'type' => 'Feature', 'properties' => array( 'title' => $programme->title, "marker-symbol" => "music" ), 'geometry' => array( 'type' => 'Point', 'coordinates' => array( $programme->programme_location->lng, $programme->programme_location->lat ) ) ); array_push($geojson['features'], $marker); } $programme_json = json_encode($marker, JSON_PRETTY_PRINT); Any thoughts? If I unpublish the last child, it returns the new 'last child' in programme. Weird?