Jump to content

Greg Lumley

Members
  • Posts

    69
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Greg Lumley

  1. Hi, I've been struggling to get menus right with bootstrap 5 and menu builder. My coding isn't good enough to pull it off. I never got my head around recursive functions very well. I find myself hacking and wasting huge amounts of time more than anything else with fragmented success. I want to redo my entire website using bootstrap 5, but not cracking the menu is really holding me back. I really really don't want to go back to Wordpress because I love PW. If you are using B5, would you mind sharing advice or code on how you're doing your menu? This is what I'm trying to emulate: https://getbootstrap.com/docs/5.2/components/navbar/ I'm using Menu-Builder, and this is the code I have, but as you'll see, it's far from elegant. I would be so grateful for any help here. Even if it doesn't use menu-builder. Thank you. <?php namespace ProcessWire; function buildMenuFromObject($parent = 0, $menu="", $first = 0) { if(!is_object($menu)) return; $out = ''; $has_child = false; foreach ($menu as $m) { $newtab = $m->newtab ? " target='_blank'" : ''; // if this menu item is a parent; create the sub-items/child-menu-items if ($m->parentID == $parent) {// if this menu item is a parent; create the inner-items/child-menu-items // if this is the first child if ($has_child === false) { $has_child = true;// This is a parent if ($first == 0){ $out .= "\n<ul class='navbar-nav me-auto mb-2 mb-lg-0'>"; $first = 1; $liClass = "nav-link"; } else { $out .= "\n\t" . "<ul class='dropdown-menu'>"; $liClass = "dropdown-item"; } } // active/current menu item $class = $m->isParent ? ' class="nav-item dropdown"' : ' class="nav-item"'; $properties = ($class == ' class="nav-item dropdown"') ? ' role="button" data-bs-toggle="dropdown" aria-expanded="false" ' : ''; $navtype = ($class == ' class="nav-item dropdown"') ? ' dropdown-toggle ' : ''; if($liClass == "dropdown-item"){$class='';}; // a menu item $out .= "\n\t<li$class $properties><a class='{$liClass} {$navtype}' href='{$m->url}' '{$newtab}'>{$m->title}</a>"; // call function again to generate nested list for sub-menu items belonging to this menu item. $out .= buildMenuFromObject($m->id, $menu, $first); if ($m->isParent) $out .= "\n";// close li $out .= "</li>"; }// end if parent }// end foreach if ($has_child === true) $out .= "\n\t</ul>"; return $out; } $mb = $modules->get('MarkupMenuBuilder'); $menuItemsAsObject = $mb->getMenuItems('Left_menu', 2); $menu = buildMenuFromObject(0, $menuItemsAsObject); ?> <nav class="navbar navbar-expand-lg navbar-light bg-light"> <div class="container"> <a class="navbar-brand" href="#"> <img src="logo.png"> </a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <?php echo $menu?> </div> </div> </nav>
  2. @bernhard This is going to be so powerful. I've done a few videos (not for dev) over the years, it sure takes a lot more time than people think it does. Good luck with that! Really looking to RockFrontend! Thank you for your work.
  3. It depends on how you've aliased the field. In this case I've used upper. It works nicely in my traditional PW setup. ?
  4. Hi Bernhard, thaks for replying. Tried that, it doesn't even output escaped characters. It crashes the server before that. As I say, it does work if I put it in the view page. home.php / home.latte All other fields that I've tested seem to work perfectly in the layout page. Since the page ID is working, I tried this. (A hack I know) {$pages->get($page->id)->SEO} Same thing, server crashes. I also check PW logs, nothing to note. My php logs aren't set up, that's the next step. Of course, I realise when it's working I will need to use "noescape"
  5. Thank you for putting me on to this, it's something to start with. I really like the neatness of it too! I'm struggling with the concept of blocks a bit... Are you by any chance using SEO Maestro? I'm finding I can't call {$page->SEO} in @layout.latte it crashes the server. If I call it in the view page it works. Obvioulsy this is an issue as that output must go in the header.
  6. Yip! But I had time this weekend and really wanted to play. Sometimes the urge should not be resisted or moved. My attention span is shorter than that of an ant. It was also a good experience to get it to work. I'm not a full time dev to say the least. ?
  7. Hi Mark, yes indeed, in fact I scoured the forum and web before asking. Even on the (Nette) Latte site, it doesn't give you a classic "Hello World" example. While Berhard shows using Latte, he does not show the steps in setting up Latte within Processwire to start with. Of course that wasn't what the post was about. That being said, I got it working, but I'm sure it's a bit of a hack. I to get it working, had to remove: <?php namespace ProcessWire; My vendor file is loaded into the PW root, I'm calling like this: Obviously this is for testing purposes. <?php require '../../vendor/autoload.php'; $latte = new Latte\Engine; $latte->setTempDirectory('latte'); $parameters['items'] = array('one', 'two', 'three'); //Get html content $parameters['html_content'] = $page->html_content; //Let's pull the images and load them to an array. $images = array(); foreach($page->images as $item){ $images[] = $item->size(600)->url; } $parameters['images'] = $images; //Let's render final output $latte->render('latte/test.latte', $parameters); ?> And the template "test.latte" <div id="content"> {$html_content|noescape} <hr> <div n:foreach="$items as $item">{$item}</div> <img n:foreach="$images as $image" src="{$image}"> </div>
  8. I feel like this could be a stupid question but I'm stumped. I'd really liked to give latte templating engine a try, but I have no idea how to incorporate it into PW. Particularly from a directory structure point of view. Do I install it in PW templates? Once that's done, what's the next step to get it working in PW? I'd really appreciate some help. Thank you.
  9. Gotta be honest, I'm really excited about this! Cant' wait for RockFrontend. I just want to jump in! Are there any "Hello Worlds" or should I just be patient and wait for the module. ? Have a great weekend.
  10. Thank you for replying Robin! I thought that was the case. Thank you also for supplying the topics too. Greg
  11. Happy 2022 everyone, I hope you have a fantastic year! A little help, please. I want to make the "Posts" page on my website the default home page. This is the site: www.greglumley.com What is the most efficient way to do this? Thank you so much. G
  12. I figured it out; it was my .htaccess file. I hadn't copied it across properly, so the mod-rewrite wasn't active. I'd also made modifications to the on-site-file which didn't work in the dev-url.
  13. Hi, I'm stumped. I have a site I've moved from the live server to a dev-server for further development. Only the home page loads, it shows up perfectly, menus and all. Clicking on any menu links give an error. I can't even get into the admin section. I'm sure this is a simple fix, but I'm unable (after hours) to figure out the issue. Any assistance would be greatly appreciated.
  14. As it turns out, the error was mine! I wasn't using the same field as I thought. page_body was correctly setup with the 'Hanna Code Text Formatter' The actual field I was using is blog_body (the disadvantage of not starting from scratch while learning) blog_body was not set up to use the 'Hanna Code Text Formatter' Thank you all for trying to help me. ?
  15. Hi, this has me stumped, please help. ? I'm using a field 'page_body' in a page-template as well as a blog-template. HannaCodeDialogue is enabled for the field page_body. HannaCode works perfectly in Pages but not in Posts. The dropdown is visible in the pages edit template but not in the posts edit template. If I manually put the code into the Posts Template i.e. : [[YouTubeVideo videoName="my_vid"]] it simply displays the tag. I'm quite sure this is a config error of some sort but for the life of me, I can't find it. Thank you. Greg.
  16. Thank you so much for for your help. I will stick with the template method since it sticks to working within the ProcessWire framework. ? G
  17. Hi, I've read up quite a bit about connecting to Ajax but it's going over my head as to how to implement it properly. I can get it to work when I put the processing script in the root but that's obviously not the correct way to do it. The page in question is a simple contact form that calls a php script using axios framework to process and send the email. This is the basic js code I have where ajax_contact.php is the processor... (linked to a form within a template.) I have read about $config->ajax etc... but still don't get how I should be implementing the "processor php script" correctly. Not that it's needed but this is the form I'm working on: https://www.lumleystudios.com/#contact axios.post('ajax_contact.php', params) .then(function (response) { console.log(response); //document.getElementById('output').innerHTML = response.data; }) Pardon me if this sounds like a dim question, I have an odd way of not seeing it the way everyone else does at time.s Thank you! Greg
  18. I'm having a little bit of a frustrating experience. Is there a way to stop CK Editor stripping certain code. I've just re-written a blog post with an unordered list. Even though CK editor includes this in the interface it doesn't like it and strips it. But not always. It seems that as the list grows it 'kills' it... How can I avoid this. ? Thanks. G
  19. I was going through the Hanna Code "Readme" in Bitpoet's editorial blog based off kongondo's Blog module and this particular line caught my attention: $f = $modules->InputfieldCheckboxes; $f->name = 'vegetables'; // Set name to match attribute $f->id = 'vegetables'; // Set id to match attribute $f->label = 'Vegetables'; $f->description = 'Please select some vegetables.'; $f->notes = "If you don't eat your vegetables you can't have any pudding.";//<<<<<<<<<<<< $f->addOptions(['Carrot', 'Cabbage', 'Celery'], false); $form->add($f); Very funny... ?
  20. Hi Rick, I'd like it to be a front-end as in "user admin", so essentially a custom front end admin. If that makes sense. ?
  21. Please pardon me if this is a silly question. I was wondering if anyone has designed a subscriber based system or any system where a user would create content and have rights to edit only that content. Something such as a listing site, craigslist etc? In my case I'd like to build some CRM management into my existing website. I'm asking roughly what your approach would or might have been ? I need a push. Thank you.
  22. Hi, I'm getting apostrophe's being rendered as HTML in the Maestro Output. What is the best recommended way to fix this? <meta name="description" content="Greg&apos;s wedding photography is fun, creative and natural. Capturing moments when know he&apos;s there. He makes you feel comfortable and his enthusiasm is infectious."> Thank you.
×
×
  • Create New...