Jump to content

renobird

PW-Moderators
  • Posts

    1,699
  • Joined

  • Last visited

  • Days Won

    14

Everything posted by renobird

  1. Marc, Nicely done. I like the subtle transitions here and there, and the overall design is super clean and easy to navigate. I love how well commented all your code is too (yeah, I'm a snoop). One thing I did notice, is that the prev/next links can get long on some items and end up pushed to 2 lines. Especially once you get down to the smaller device sizes. It's not really a huge deal, but it might be nice to have the prev/next links show the item name on hover for the larger widths, and then maybe just hide the name all together at smaller device widths. This are all opinions of course, and very nitpicky suggestions—overall it's a very nice site.
  2. Soma, Thanks! That works great.
  3. Hi Ryan, Thanks for the reply, that helps me understand the images field a lot better. Turning $user->of() on/off helped solve my initial issue, but I'm still not sure how to solve what's happening now. Maybe you can help me find away around what's happening when I try to set a new user image via the API? In ProcessWire I have "max files" set to 1 on the user images field. So when a new image is uploaded to that field from within ProcessWire, the old image image gets overwritten in the file system and only the new image shows in ProcessWire. That's the behavior I would expect. However, if I upload a new image via the API, it does not overwrite the old image, and the new image is "added" to the images field in ProcessWire. I thought I could solve that by setting the image filename via the API (which would still leave multiple images in the filesystem, but just show the most recently uploaded in the admin) $user->images = $fileName; However, multiple images still show in ProcessWire, and when I try to reference the latest image for that field via the API, it always shows the oldest image. $user->of(true); $image = $user->images; if ($image) { echo "<img src='{$image->url}' height='{$image->height}' width='{$image->width}' alt='{$image->get('description|name')}' />"; } $user->of(false); Ideally I'd like the admin and the API function the same when modifying the images field. (i.e. use the "max files=1" setting and either overwrite images in the filesystem, or at least not add them in the PW admin. I'm a little stumped on how to make that happen.
  4. I'm a bit over my head here, but... Even though I have the field "maximum allowable files" set to 1, it's still allowing me to add multiple images via the API. I'm setting the image for that field via: $user->images = $fileName; Where $filename is "myFileName.jpg", after it's been sanitized. If I turn user output formatting on, I get an image, but it's always the original image that was uploaded, not the latest image. $user->of(true); $image = $user->images; echo "<img src='{$image->url}' height='{$image->height}' width='{$image->width}' alt='{$image->get('description|name')}' />"; $user->of(false); however, if I leave user output formatting off and use a foreach, I only get a single image returned, and it's always the latest image I uploaded. foreach ($user->images as $image); echo "<img src='{$image->url}' height='{$image->height}' width='{$image->width}' alt='{$image->get('description|name')}' />"; Like I said, I'm a bit over my head—and super new to PW—so I'm not sure if any of the above was helpful.
  5. returns /site/assets/files/41
  6. Soma, If you can't reproduce it, then it's likely I'm doing something wrong. I've double checked that I'm using the correct field. Code: $image = $user->images; echo "<img src='{$image->url}' height='{$image->height}' width='{$image->width}' alt='{$image->get('description|name')}' />"; produces: <img src="/site/assets/files/41/" height="" width="" alt="" /> If I use this I get the desired results: $image = $user->images->first();
  7. Hello All, I have an images field that has "maximum files allowed" set to 1. My understanding is that calling that field should now return a single image and not an array. However, when I use: $user->images it's still returning an array. If I use: $user->images->first() I can access the image. Either I'm doing something else wrong, or this is unintended behavior.
  8. Hello All, I've be able to successfully view and edit user profile info from the API. (I can't believe how simple it is actually.) I'm a little stuck on how to update a users profile picture. I have an image field name "images", and I can pull that image and display it. I'm just not sure how to process a replacement image if one is chosen in the <input type="file" name="images" /> field. Any pointers would be much appreciated.
  9. *crickets*
  10. Thanks Steve, I'll log into the channel when I'm back at work tomorrow.
  11. Hello All, Is there currently a native method or module that would allow me to make bulk edits? For example, I need to change the template that 2 dozen pages use — editing them one at a time is taking quite a bit of time. I haven't had to delete a lot of pages yet, but I can see where that could get tedious too. *I suppose I could just update the DB via SQL, but ideally I'd like to be able to stay in the admin.
  12. I've used JS to suppress those links in the past. I've just always wondered how it effects search engine results, since the url still actually gets displayed, so the page will get crawled. If it's set to '#", then it's basically invisible. I'll explore the redirect route, I think that would solve any issue with "dead" URL's floating around. Thanks.
  13. Thanks Soma, Again, apologies for the false alarm. I do have another (hopefully legitimate) question. Is there a way to optionally suppress the href attribute on top level parent items? Meaning, if the "has_children" class is set then the href for that top level item would be set to href="#" A lot of times I find that the parent items are just containers for the children. So if you link to them, there really isn't a need to have anything there. There's a great Textpattern plugin (adi_menu) that has this functionality, and I've just realized how much I use it.
  14. Bah! I spotted it as soon as I posted this code. My "parent_class" and "has_children_class" are set to the same thing. That's what is causing it to act like it's showing up again. My apologies for the wild goose chase. *Bad Renobird, Bad...*
  15. Hi Soma, Sorry, meant "has_children". <?php $treeMenu = $modules->get("MarkupSimpleNavigation"); $options = array( 'parent_class' => 'parent', // string (default 'parent') overwrite class name for current parent levels 'current_class' => 'current', // string (default 'current') overwrite current class 'has_children_class' => 'parent', // string (default 'has_children') overwrite class name for entries with children 'levels' => false, // bool (default false) wether to output "level-1, level-2, ..." as css class in links 'levels_prefix' => 'level-', // bool (default 'level-') prefix string that will be used for level class 'max_levels' => 3, // int (default null) set the max level rendered 'firstlast' => true, // bool (default false) puts last,first class to link items 'collapsed' => false, // bool (default false) if you want to auto-collapse the tree you set this to true 'show_root' => true, // bool (default false) set this to true if you want to rootPage to get prepended to the menu 'selector' => 'parent!=1011', // string (default '') define custom PW selector, you may sanitize values from user input 'outer_tpl' => '<ul id="nav" class="clearfix">||</ul>', // template string for the outer most wrapper. || will contain entries 'inner_tpl' => '<ul>||</ul>', // template string for inner wrappers. || will contain entries 'list_tpl' => '<li%s>||</li>', // template string for the items. || will contain entries, %s will replaced with class="..." string 'item_tpl' => '<a href="{url}">{title}</a>', // template string for the inner items. Use {anyfield} and {url}, i.e. {headline|title}, if field is of type image it will return url to image (first image if multiple) 'item_current_tpl' => '<a href="{url}">{title}</a>' // template string for the current active inner items. ) ?> Called like so: <?=$treeMenu->render($options);?> Let's say I have this nav structure (simplified): home portfolio --project 1 --project 2 --project 3 --project 4 --project 5 etc... about-us --meet the staff --history services --stuff we do --more stuff we do contact us The "portfolio" page is the one I want to omit children from because it could have a lot of children, and the drop down menu gets too long. 'selector' => 'parent!=1011' corresponds to that page. What happens now is that if I visit: /portfolio/ There is no "has_children" appended. But if I visit: /portfolio/project-1 the "has_children" class shows up again.
  16. Hi Soma, Thanks for this plugin. I'm just putting it through the paces, and I noticed something related to the "has_children" behavior your mentioned above. If you specify something like: 'selector' => 'parent!=1011' The "has_parent" class isn't appended on the first level, but deeper than that it shows back up. For example, there's no "has_parent" appended for 1011 for: / /about-us/ etc... But it does get appended for something like: /about-us/meet-the-staff/ etc... Maybe I'm doing something wrong and need to set something differently in the options array, but from what I can tell this doesn't seem like the behavior you intended.
  17. Thanks Pete, ListAfterSave might help a little, but if I could avoid having to go back to the tree at all that would be great.
  18. Hi Ryan, When adding and editing siblings, going back and forth to the page tree seems to slow down the process quite a bit. What if there were links to some common things like: prev, next, add new (or add sibling) when you are in edit mode? I attached a quick mockup, not necessarily for placement purposes, just as a visual aid. I'm still very new to PW, so there might be better methods already, just thought I would throw this out there as a feature request.
  19. Soma, Thank you! That's the kind of solution I was hoping the API would provide. The headline|title is a great example too, I'll be using that for sure.
  20. Wow! You planning on releasing that as a module? *fingers crossed*
  21. Thanks Pete! I was initially trying something with !empty(), but it was getting too verbose — I forgot about ternary operators. My PHP skills are pretty rough.
  22. Steve, Perfect! And that makes complete sense. I was thinking there might be some fancy way with the API. Thanks for the quick reply. I'm sorting out PW methods for all the things I do in TXP with tags like chh_if_data.
  23. Hello all, If I'm using the {$image->description} to populate the alt attribute, is there a simple method to show {$image->name} if the description field is empty? Example: <? $image = $profile->images->first(); echo "<img src='{$image->url}' height='{$image->height}' width='{$image->width}' alt='{$image->description}' />"; ?>
  24. Pete, Great examples. The pipe serving as the 'or' in the last example is really cool.
  25. Thanks all — things are becoming a bit clearer now. I think it's just a matter of convincing my brain to look at things from the perspective of the API and not raw PHP. I'll study up on the cheat sheet some more, and try not to ask these rudimentary questions. No promises though.
×
×
  • Create New...