Jump to content

a-ok

Members
  • Posts

    812
  • Joined

  • Last visited

Everything posted by a-ok

  1. @flydev Thanks for your help. I'm wondering... if I set a session... I should be able to see it being set in Chrome DevTools > Application > Cookies, right? But I'm not so unsure if I'm even setting it correctly. Does session_start(); need to be initialised, or is it set by PW already?
  2. Thanks @Wanze! Referencing what @flydev said; do you think this would still work? I'm confused because if the limit was 8, for example, when it got to '8' items would it not just reset to 0?
  3. Not sure! I echo out the count per item and it's always 0.
  4. I have a simple loop that is returning a different layout if the $count is odd or even (image on left, text on right if odd and text on left, image on right if even). I've then set this up with Waypoints Infinite Scroll which is essentially an AJAX loading of content from the next page and therefore, as the $count is server side but the AJAX is client side, it breaks the count and therefore every item that is loaded in the 'else' even layout. Is there a way to do this to it keeps the $count and would return correctly? I thought about using $session and storing the variable but wasn't sure I had this set up correctly. Any thoughts on the below? <?php $limit = 1; $news = $pages->find("parent=/news/, sort=-news_detail_date, limit=$limit"); $total = ceil($news->getTotal() / $limit); ?> <?php $session->set('count', 0); ?> <div class="news--layout"> <?php foreach ($news as $article) : ?> <?php include('./inc/news-item.inc'); ?> <?php $session->count++; endforeach; ?> </div> And in my 'news-item.inc' I have something like... <?php if ($session->count % 2 != 0) : // Odd ?> <?php else : // Even ?> <?php endif; ?> Thanks.
  5. Anybody have any further thoughts on this? Struggling to work this out...
  6. I'm thinking something like this but wasn't sure on if the ->add() is missing? $exercises = $pages->find("parent=/undervisning/"); foreach ($exercises as $exercise) { $exercise->of(false); $old_repeater = $exercise->training_detail_flexible_content; // Old repeater matrix $new_repeater = $exercise->training_detail_flexible_content_block->getNew(); // Add repeater row to new repeater foreach ($old_repeater as $old_row) { // For each row in old repeater matrix $new_row = $new_repeater->training_detail_flexible_content->getNew(); // Add repeater matrix row within repeater $new_row->repeater_matrix_type = 1; // Set the type of the repeater matrix row (text) // By here we should have a new repeater matrix row (type=1) added within the repeater to match the old repeater matrix rows // Now to transfer the text across $new_row->training_detail_flexible_content_text = $old_row->training_detail_flexible_content_text; // Save each repeater matrix row added $new_row->save(); } // Save the whole new repeater $new_repeater->save(); // Save page $exercise->save(); }
  7. I'm working with a client who had uploaded 70+ articles into the CMS and used a RepeaterMatrix (training_detail_flexible_content) to add a number of 'modules' per article. Since then we wanted to do something a little different so I have created a Repeater (training_detail_flexible_content_block) and within that repeater is the RepeaterMatrix (training_detail_flexible_content) which has text, video, and image modules. I'm trying to work out a way, for each article, to essentially 'copy/paste' the old text module fields into the new one. I've done this before but only when there was one text field into repeater whereas there's multiple text modules per article. This is what I had before below. Any advice? $articles = $pages->find("parent=/articles/"); foreach ($articles as $article) { $article->of(false); $repeater = $article->article_content->getNew(); $repeater->repeater_matrix_type = 1; $repeater->article_content_text = $article->article_text; $repeater->save(); $article->article_content->add($repeater); $article->save(); } You can see below that the first lot of modules is what we previously had and I want to move them into the first repeater row of the Repeater with the exactly the same order etc.
  8. That's what I thought but simply trying something as quick and easy as this (1156 is a repeater row page). $test = $pages->get(1156); echo $test->title; returns nothing
  9. I couldn't find an answer to this but is it possible to use ->get() (to retrieve one page) that's a repeater page (i.e hidden). I wasn't sure if you could add "include=hidden" to a ->get(). Thanks!
  10. Ah maaan. It's just weird that if I copy the original into /sites/ and use that it doesn't work (so it's not modified... just in a different location).
  11. Thanks @Robin S this makes sense. One thing I noticed though, specifically with copying and using ProcessPageEditLink.module is that it didn't create the tab 'Attributes' but rather stuck the Attributes content (when editing a link in the modal) at the bottom. As soon as I switched it to the /wire/ version it worked. So I copied that whole file, as it is, into /site/ and it did the same thing. Weird.
  12. That's great @Robin S – so copying files to the same directory under /site/ allows for custom overwriting... this is great. Thanks for the other info too. I have managed to manipulate /wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.module so should do the same for that too I guess! I realise it gets a little dodgy doing things like this but won't be updating the version once it's live.
  13. Another question would be... is it possible to edit the 'wire/modules/Inputfield/InputfieldCKEditor/plugins/pwlink/plugin.js' file within '/site/templates/' as an extension so updates don't override any added/adapted code?
  14. I've had a bit of a look around but cannot find anything but is it possible to create your own CK Editor toolbar button and custom behaviour? I am wanting to use 'annotations' in the text field so if the user highlights a piece of text, then clicks a CK Editor toolbar custom button, it links the piece of text to an annotation (either create the annotation there and then (title, media, summary, source title and source url) OR select a repeater row from a separate 'Annotations' field further down the CMS editing page) – any thoughts or suggestions?
  15. Think I'll try this... ob_start(); include('./inc/training-item.inc'); $out .= ob_get_contents(); ob_end_clean();
  16. Is there a way to do this without including the HTML markup as part of the $out? For example... foreach ($pages_ as $p) { include('./inc/training-item.inc'); }
  17. Okay I'll maybe go down that route. One last thing; if I am wanting to loop through results ($pages->find) rather than ($pages->get) what's the best way to do this? I can output it as PHP but unsure how to do it as JSON data for the AJAX call?
  18. Ah yes I missed that too If I was calling a separate page, so I could run a nice loop template, is there any reason why it would return a 500 server error? Say, in /site/ajax/ajax.php I had your PHP code and in the JS I had url: rootURL + 'site/ajax/ajax.php', is there anything that would throw this off? It works fine within the same page... just not when I request the ajax.php file.
  19. @fbg13 Super appreciate the help. I seem to get an error with '$sanitize' as if the JSON is thinking it's a JS variable? Any thoughts?
  20. @fbg13 This looks super useful. Can I ask... what is 'ajaxURL'? Should this be the page where the PHP you included should exist?
  21. Thanks @kongondo! What I've done previously to create the filters as a form (as I had multiple filters) that push the selected filters into an input then I retrieve these using $input->get which would update a $pages query on a new page. I'm wondering if this is possible without using a form. I'll keep thinking. Thanks for your help.
  22. Thanks both. I thought as much. I knew I could implement some form filtering and call the results via AJAX but I thought perhaps there was a way to manipulate the $pages query per click. I realise it's a pretty dumb question in hindsight.
  23. I'm wanting to set up a list of filters (that would change the original $pages query) and wondered if this was possible to do via AJAX with PW? <?php $limit = 20; $exercises = $pages->find("parent=/uddannelse/, sort=-training_detail_date, limit=$limit"); ?> For example, I might implement a sort filter (A-Z or DATE) which would update the 'sort' field to '-name' rather than '-training_detail_date'. Or, I might implement a category filter so on click it would update the $pages query to: <?php $limit = 20; $exercises = $pages->find("parent=/uddannelse/, sort=-training_detail_date, training_detail_category=123, limit=$limit"); ?> Any thoughts? Thanks.
  24. Thanks all! @Robin S I went with your PHP solution... like it avoid hiding via CSS.
×
×
  • Create New...