Jump to content

creativejay

Members
  • Posts

    259
  • Joined

  • Last visited

Everything posted by creativejay

  1. This clears the undefined variable error, but there's no output for the value of $field, nor even if I create a custom field called "f" and add a value. In fact I'm noticing the code seems only to work if I use $child->headline or $child->title. Anything other static field name from this page outputs nothing. This tangle is getting worse and worse.
  2. I'm gnawing on this bone again, folks. I was trying to do something else, iterating through fields in a page, and realized I had half of what I needed already working from this thread. But tying them together is giving me trouble, which I think is in regard to the way the API and php are working together. $children = $page->children; $fields = $children->first()->template->fields; echo "<table width=100% border=1><tr><th><strong>Field (fieldType)</strong></th><th><strong>Field Value (children that share the value)</strong></th></tr>"; foreach($fields as $f) { // fields first if($f->type != FieldtypeFieldsetTabOpen|FieldtypeFieldsetClose){ echo "<td valign=top align=left>{$f->label}<br />({$f->type})</td>"; $byField = array_reduce($children->getArray(), function($carry, $child){ $carry[$child->$f][] = $child; // HERE IS MY ISSUE return $carry; echo count( $carry ); }, array()); $toTextBlocks = array_map(function($field, $children){ $childrenPA = (new PageArray)->import($children); return "$field (" . $childrenPA->implode(", ", "title") . ")"; }, array_keys($byField), $byField); $line = implode(", ", $toTextBlocks); echo "<td valign=top align=left>". $line . "</td></tr>"; } } echo "</table>"; So in the line commented of note, there seems to be a disconnect between $child->$f and my intended $child->field_name. TracyDebugger says $f is undefined at this point, but we are inside the loop where $f should be defined. I'm at a loss at the moment. I'm working on this as well but I'm reaching out in the hopes one way or another I find the solution today. Thanks in advance!
  3. Thank you for taking a look! This is still not outputting anything, unfortunately. I'm fussing about with it and will update if I catch on an answer, but if anyone else is taking a look at this I am still seeking the solution. Thanks!
  4. My brain is probably just tiring out on me right this moment, I'm hoping that by the time I write out my problem I'll see the way through it. If you're reading this, it didn't work. Structure in question is: Series Page Product pages Page Fields for each product page Some of these fields are repeaters Fields within the repeater I have made an array of page fields so I don't have to keep track of them all as I develop: $listings = $page->children; // grab all the published children of the Series page foreach($listings as $l) { // loop through the children foreach($l->fields as $f) { } // loop through each child's page fields where they have a value set } Then I break down how to handle each type of field: if($f->type == 'FieldtypeFile') { } elseif($f->type == 'FieldtypeDatetime'||$f->name == 'prod_status_pages'||$f->type == 'FieldtypeImage'){ } elseif($f->type == 'FieldtypePage'){ } These are all largely working as expected (though I do have a couple of offset/isset exceptions to clean up...) It's when I get to the repeaters that I run into trouble getting the API calls to work. Just cycling through the fields as above, the output for a FieldtypeRepeater is the ID of the repeater in that field's array. Everything I read suggests I should treat a repeater the same as I would treat a page, which leads me to the following code. elseif($f->type == 'FieldtypeRepeater'){ // Repeaters need special treatment otherwise output is just ID $th .= "<th><b>{$f->label}</b></th>\n"; $trows = ""; // creating an empty variable to build my foreach into foreach($f->fields as $rf){ // looping, I hope, through the fields of the given Repeater ID $trows .= "{$rf->label}: {$f->get($rf)->title} ({$rf->type})<br />\n"; // add an entry to the variable } $rows .= "<td style='padding: 8px 16px; vertical-align: middle;'>".$trows."<br />\n ({$f->type})</td>\n"; // back out to rendering the Repeater field } What I would hope would output in the HTML I've been building is something like: <td style='...'>Lo temp: -40 (Integer)<br /> Hi temp: 75 (Integer)<br /> Storage Lo: -40 (Integer)<br /> Storage Hi: 85 (Integer)<br /> Functional to: 85 (Integer)<br /> (FieldtypeRepeater)</td> So what I'm trying to do here is loop through the populated fields in the unknown Repeater field, and output them as a simple (so far) text list of the repeater.field and its value (and then its type for my reference). I'm afraid typing this out has fixed some syntax but not enough to get this working as I'd hoped. Please note not all Repeater fields are integers. Some also have floats, files, or options, and probably a couple others I'm forgetting. I appreciate your time in taking a look at this!
  5. I am having a complete failure to comprehend the way this field is structured, so while I can use the provided examples to render a list or calendar, from the individual pages I can't manage to access the individual date(s) in the field. I sent this question to the help email address on Tuesday but haven't received an answer and I'd like to wrap up what seems like it should be a simple thing. While working on the template for an event page, how do I specify the RecurMe dates from within that template using $page->xxx? For instance I would normally echo a dateTime field like: $datefield = $page->datefield; $pubdate = strftime('j M Y', $datefield); echo $pubdate; // outputs nothing But since my recurme field, $page->eventsort, is an array(?), I figured I’d have to crack open the array first like so: $eventsort = $page->eventsort; foreach ($eventsort as $event) { //it loops through one $event because there is only a non-repeating day listed. $pubdate = $event->startDate; echo strftime('j M Y', $pubdate); // outputs nothing } I used startDate because when I once got the array to output, that was what was listed there. But this returns null. Same with start_date/date/any $event page fields listed in the faqs I also tried : $event = $page; $newsdate = $recurme->event($event); //not sure this is any different than attempting to call $page->xxx? $nd = $newsdate->start_date; echo strftime('j M Y', $nd); // outputs "j M Y" on the page. I've looked in the module files, and in the ready.php hook on page 1 of this thread to see how to take apart the field data, but nothing I've tried has worked. So rather than continue chasing my tail, I thought I might as you for help with this as well. Thanks!
  6. Here's what I ended up with: $artthumb = ''; if(count($a->images) > 0) { $artimage = $a->images->first(); $artthumb = $artimage->url; if($artimage->description) { $imgdescript = $artimage->description; } else { $imgdescript = $a->getUnformatted('headline|title'); } echo "<div class='col span_1_of_12'>"; echo "<img src='{$artthumb}' title='{$imgdescript}' class='article-img' />"; echo "</div>"; } elseif (strpos($a->body, "<img") !== false) { $texthtml = $a->body; preg_match('/<img.+src=[\'"](?P<src>.+?)[\'"].*>/i', $texthtml, $image); $artthumb = $image['src']; $imgdescript = $a->getUnformatted('headline|title'); echo "<div class='col span_1_of_12'>"; echo "<img src='{$artthumb}' title='{$imgdescript}' class='article-img' />"; echo "</div>"; } $a being the individual page in the foreach($articles as $a) loop.
  7. Yes that does the trick for detecting the image, thanks, but how can I go about referencing the first image from $page->body in the template php?
  8. I have a page which lists articles, and if there are images uploaded via the images field for that page, a thumbnail is displayed next to the article headline. However for a number of pages, I will be placing an existing image from another page in the tree into the body field. In these cases, is there anyway to check the body field's content for an image so I can display that in the article list? Logic would be: If the image field has one or more images uploaded { get first and display as thumbnail } elseif the body field has one or more images placed from another page { use the first body image as the thumbnail } else { omit thumbnail } Anything I can try that would work as shown (or is there an alternative to consider)? Thanks in advance!
  9. Thanks for the lovely module, kongondo! Before I commit, could you tell me if updating an existing image will create a new asset that must be re-linked, or can I overwrite an existing image and have all the proper associations update automatically? (Sorry if this was already addressed, I tried to search for the answer but my keywords (overwrite/replace/existing) each only came up with talk of upgrading the module itself.)
  10. That's great BitPoet, thank you! Works as advertised in my 3.0.42 installation. I'll flag it to keep an eye on after future updates, though. Thanks again! ETA: It does seem to cause a conflict with the user page edit, FYI anyone who comes along later. I'll just turn it on and off when I need it and then remove it before the site goes live. Or see if I have some time to try and debug it.
  11. Yes once I use it once it remembers, but I just was hoping for a cleaner approach to it since there's already a tab for that page's "Family" ifyaknowaddimean.
  12. It's a little better with the modal tree, but I still end up doing a lot of clicking around. I'm hoping for two clicks (sibling tab, there it is, click to edit if I want to jump to it).
  13. Just one of those things I often find myself wishing for: Could a future update add a "Siblings" list tab (or make a "Children & Siblings" combined tab) to /page/edit/? Save + Next is a godsend, but in many cases I need to jump around instead of cycling through. Sometimes I just want to reference how I titled other pages under one parent to keep the naming consistent. Other times I'm deep enough in my page tree that it's a half-dozen or so more clicks than I'd like to get back to where I was. So far my workaround is to right-click on the parent's name in the Breadcrumb nav, and open the page tree in a new tab. But when editing a site often has me opening ten or more browser tabs at a time, each one I can cut out is a blessing. Thanks for your consideration!
  14. Is DynamicRoles meant to be compatible with PW 3.x at this time? I would love to use it to control Page Publish permissions in a new installation. I see gitHub mentions of correcting installation on 2.8/3.0 but the description only mentions 2.4.5+ and I don't see a lot of recent activity for the module there. Or has some new module/Process replaced this?
  15. Thanks adrian! I've saved this folder for future installations to make it faster. I was certain it was a cache issue but my real issue was webhost related. I fixed it and it works like the charm I knew it would! (I'm sure I'll be back as I customize these files, but hopefully I'll think through all my possible user-errors first!)
  16. Whoops, Ultra-PEBDAC. (I was asking about the font issue that adrian kindly resolved below, but my real issue was that I was uploading files to the wrong server - we are in the midst of switching hosts!)
  17. Yes, it's only the template. I turned off the ML support since we only actually have one article out of 150 that has another language available, anyway. That hasn't fixed anything. I can't figure out what might be invoking it, the template is pretty much identical (setting-wise) to other templates with parent/child pre-set. I made a new template, copying the fields of this one, but the settings for the template didn't come across so only the allowed parent setting was changed from the default, and it still is happening. It doesn't happen on pages created from other templates with identical settings.
  18. Ah, thank you! It had been so long since I set it up the first time I didn't remember having to set that up in the Home settings. That part's sorted out now, thanks! Still can't figure out why the page creation is switching back to an automated name.
  19. I am manually duplicating a 2.7.x site in a 3.0.33 installation, and have run into a couple issues. First, with my language support, a couple of my languages (German, Finnish, English) have the correct url segment (de, fi, en). The rest (French, Italian, Polish, Portuguese, Spanish) all have their url segment showing as 'en' even though I have set them properly under Setup / Languages (I even tried to change these and it did nothing). Second issue: as I create a page of a certain template, the Title and name I input on the initial creation/template selection page is not saved, and instead I get an auto-gen'd name and the title is blank after I click Save. I haven't experienced this with any other templates, and I don't see anything odd about the template settings. If I didn't have a couple hundred of these pages to add to the site, I wouldn't mind figuring it out later, but with that quantity I'd like to sort it out at the start. Creating the page (the template is auto-selected because of the parent page): Then after it's saved, the Content Tab has no Title entered and the Setup tab has the default name: Appreciate any insight from someone who may have run into this already! Thanks!
  20. Ah, thank you! I was trying to find what version that was created for, and wasn't able to track that info down. I'm working on the latest stable because I need to launch this site the very minute it's ready. Which bugs me because there are SO many features I want to use that are in PW 3.0.x.
  21. That's the first thing I tried but kept getting the error: Error: Exception: Method Page::getLanguages does not exist or is not callable in this context (in /wire/core/Wire.php line 358)
  22. So there's nothing to call via the API that is true/1, only when a page has multiple active languages? Your solution definitely works around that shortcoming, and now I can move forward. Thank you!
×
×
  • Create New...