Jump to content

kongondo

PW-Moderators
  • Posts

    7,529
  • Joined

  • Last visited

  • Days Won

    161

Everything posted by kongondo

  1. I already answered how to do this . If you don't want pagination, then, in your case, grab only 1 item. // GET 1 post, SORTED BY created {you could also sort by '-blog_date'} $singlePost = $pages->get('template=blog-post, sort=-created, blog_categories=News'); $out = $blog->renderPosts($singlePost); echo $out; I am not being rude but this is the point at which I encourage you to get that 'PHP for beginners' book (e.g., this one) as well as revisit the PW docs. Let's walk through your code: Line 1#: You grab some posts using find(). That returns a PageArray. You then assign it to the variable $posts. Line #3: You are overwriting the variable $post (which contains the PageArray from Line #1), assigning it an empty string, i.e. ''. Line #4: You are appending to the empty string $post an Object which contains the current page's image. Line # 6: You then append to $post other stuff..... That's why it doesn't work as expected . I am surprised it didn't throw an error. Maybe you have debug turned off?
  2. I have no idea why you have such a setup but anyway, here goes. As per the instructions, your Hook needs to return a PageArray. This is untested: $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->name == 'result_judge_challenge') { $page = $event->arguments('page'); $event->return = $page->parent->parent_multi_page_field;// this should return a PageArray } }); You might want to add checks to see if the parent page actually has items in its page field.
  3. I am not sure I understand this one. Not sure if you want 1 post from 1 category or several posts from 1 category. Irrespective, pagination only kicks in when you grab a limited number of items and the results returned are a PageArray. If what you mean is: 1. Render only 1 post from a given category: Here the trick is to return a Page rather than a PageArray. So, we use a get(). findOne() (if you are using PW 3.X) should also work. $content = ''; // render a single blog post on Blog Home Page //$singlePost = $pages->get(11335);// grab by ID $singlePost = $pages->get('template=blog-post, sort=random, blog_categories=News Article, limit=1');// grab a random post $content .= $blog->renderPosts($singlePost); 2. Render several posts from only 1 category. In this case, this will return an array. So, to avoid pagination, we need to grab ALL the available post, i.e. no limit (careful with this one if you have lots of posts!). $content = ''; // render ALL blog posts from a single category on Blog Home Page $oneCategoryPosts = $pages->find('template=blog-post, blog_categories=News Article'); $content .= $blog->renderPosts($oneCategoryPosts); // these will also work; passing in a selector #$selector = "template=blog-post, blog_categories=News Article"; #$content .= $blog->renderPosts($selector); No need to create a different template for blog posts classified as 'News Article'. Instead, we include some extra logic in the template file blog-post.php. See example below. // get the category 'News Article' $newsArticle = $pages->get('template=blog-category, name=news-article'); // special render for blog posts that are classified under 'News Article' if($page->blog_categories->has($newsArticle)) { $options = array('post_categories'=>1, 'post_tags' => 0);// options ONLY for news articles $renderAuthor = '';// don't render blog post author for news articles $renderComments = '';// ditto comments } // normal blog post else { #$options = array();// if you wish, options for all other blog posts go in here $renderAuthor = $blog->postAuthor();// render authors for normal blog posts $renderComments = $blog->renderComments($page->blog_comments);// ditto comments } $content = $blog->renderPosts($page, false, $options) . $renderAuthor . $renderComments . $blog->renderNextPrevPosts($page);
  4. Hmm...what does this mean then? You want to be able to edit these where? In the backend?
  5. Not sure I follow fully, but it looks like you are creating a form builder? You say you want various parts of the form to be editable? If that's the case, I would invest in FormBuilder.
  6. Mod Note: Moved your topic here as it is not a ProcessWire question but a general dev one.
  7. I am not sure I follow either but I'll have a go . Is $page->alias a string or an integer? I am curious since you do this: author.id=$page->alias. Did you create your own field called id or is that the inbuilt page ID? I don't understand the foreach question. If what you are after is matching multiple values or multiple fields, then what we use are pipes |. See this docs. You say you would like to match publications by either name or their alias. However, the examples you give are not using or selectors; they are using AND selectors (i.e. comma separated selectors). See those docs for the differences.
  8. Hmm...I don't think it's possible. But you never know!
  9. True, but not sure Ryan is monitoring issues in the old repo .
  10. Just a quick by the way, I recently updated the first post in this thread to state that the wireRenderFile() approach is the recommended way to use this module. I'll update the README too when I get the time.
  11. Maybe we should file it as a bug...(which it is, since it has been implemented since 2.5.22 but it's not working), rather than a request?
  12. Excellent! Have upvoted the new one. We will also need to update the Docs. The selectors docs says it doesn't work; the blog post says it does .
  13. Do those variations have to be searchable? E.g. Should users be able to search for, say, a Purple shirt, of size M and material Cotton? If yes, then we could be talking a DB table for each variation with foreign keys to link the products. If not, then you might just about get away with storing everything in one column of a table using, say, a JSON string.
  14. You are right, Benjamin. If one changes the selector to match only 1 parent like shown below, the two finds become equivalents. // these two are equivalents $items = $pages->find("template=minimal, has_parent={$page}, limit=10"); $items = $pages->find("has_parent={$page}, template=minimal, limit=10"); Do you know if a bug report has been filed about this?
  15. Actually @LostKobrakai, it does as of ProcessWire 2.5.22? No? https://processwire.com/blog/posts/processwire-core-and-profields-updates-2.5.22/#has_parent-selectors-now-support-multi-value
  16. FWIW, here are the resultant queries (similar, not identical to yours) for the two finds: Find 1: $categories = $page->children("template=blog")->add($page); $selector = "template=blog-post, has_parent={$categories}, limit=7"; $query = wire('pages')->getPageFinder()->find(new Selectors($selector), array('returnQuery' => true))->getQuery(); echo $query; Resultant Query: SELECT SQL_CALC_FOUND_ROWS pages.id,pages.parent_id,pages.templates_id FROM `pages` WHERE (pages.templates_id=77) AND pages.parent_id IN (SELECT pages_id FROM pages_parents WHERE parents_id=3545 OR pages_id=3545) OR pages.parent_id IN (SELECT pages_id FROM pages_parents WHERE parents_id=3560 OR pages_id=3560) OR pages.parent_id IN (SELECT pages_id FROM pages_parents WHERE parents_id=3565 OR pages_id=3565) OR pages.parent_id IN (SELECT pages_id FROM pages_parents WHERE parents_id=1044 OR pages_id=1044) AND (pages.status<1024) GROUP BY pages.id LIMIT 0,7 Find 2: $categories = $page->children("template=blog")->add($page); $selector = "has_parent={$categories}, template=blog-post, limit=7"; $query = wire('pages')->getPageFinder()->find(new Selectors($selector), array('returnQuery' => true))->getQuery(); echo $query; Resultant Query: SELECT SQL_CALC_FOUND_ROWS pages.id,pages.parent_id,pages.templates_id FROM `pages` WHERE pages.parent_id IN (SELECT pages_id FROM pages_parents WHERE parents_id=3545 OR pages_id=3545) OR pages.parent_id IN (SELECT pages_id FROM pages_parents WHERE parents_id=3560 OR pages_id=3560) OR pages.parent_id IN (SELECT pages_id FROM pages_parents WHERE parents_id=3565 OR pages_id=3565) OR pages.parent_id IN (SELECT pages_id FROM pages_parents WHERE parents_id=1044 OR pages_id=1044) AND (pages.templates_id=77) AND (pages.status<1024) GROUP BY pages.id LIMIT 0,7 I am guessing (am no SQL guru) the key thing is that we are dealing with an AND selector, maybe? Edit: Me thinks this is a bug in the selector engine itself?
  17. Maybe this Admin Actions by @adrian, as a starting point? https://processwire.com/talk/topic/14921-admin-actions/?do=findComment&comment=137919 Edit: And this too, earlier today https://processwire.com/talk/topic/15449-how-to-add-repeater-items-to-repeater-inside-repeater-matrix/
  18. It has to be an array, yes. According to that warning, it says nothing (not empty, but nothing) is being returned by $input->get->cb_sectors. Do you have a typo somewhere? Maybe if we saw the whole code we could better help.
  19. Which part is not working? Is $selected not getting applied or it is being applied multiple times (even when it shouldn't)?
  20. Wondered about that but too but it seems there could be upwards of 3 variations, e.g. colour, size, fabric as well as price.
  21. That, actually, has nothing to do with MSN (from what I can tell). It's called CSS ....the styles are cascading. You need to solve this in your CSS file.
  22. @rolisx, Mod Note: Please use code blocks around code in your posts (see the <> icon).
  23. I see at least three options: An auto-load module (might be an overkill though) that will copy the title to the address JavaScript via a module like RuntimeMarkup, which you could then hide from being visible on the page. Or even better, the module AdminCustomFiles Copying and modifying the Leaflet module itself to suit this need So yes, it is possible .
  24. Hi @swampmusic, I see that you've already asked the same question here : As per the rules, multi-threading is not permitted . I note you haven't received an answer yet in the other post. However, I'd ask for a bit more patience on your part. I'll lock this thread and will attempt to answer the question in your original post.
  25. This, partly, looks like a job for Profields Table? However, this... ...seems like you need the dynamism to be created during page edit.
×
×
  • Create New...