Jump to content

kongondo

PW-Moderators
  • Posts

    7,479
  • Joined

  • Last visited

  • Days Won

    146

Everything posted by kongondo

  1. I've tried intelephense and it's not working for me. Only PHP functions show up. Anything I might be missing? I'm on windows 7
  2. Not sure if this thread is still relevant? If it is, it seems cloning repeaters can be a pain ?? Btw, this: $block = $salespage->children("id={$duplicate_id},include=all")->first(); Can be shortened to this: $block = $salespage->child("id={$duplicate_id},include=all");
  3. A similar question regarding comparisons of the 3 main PHP intellisense extensions https://github.com/bmewburn/vscode-intelephense/issues/128
  4. @AndZyk. Thanks to you and @bernhard, I'll now try intelephense. Bottom line is the snippets I created have no advantage over intelephense from what I've read and seen :-).
  5. It does look nice! Felix's would struggle with variables from included files (something that worked in ST out of the box). It would also struggle with variables from new Page(), etc. If you try the intellisense of other languages such as JavaScript or Python, you'll be amazed. If I called something similar to $blog = $modules->get("MarkupBlog"), they will pick up on the methods and properties in MarkupBlog! Do you get that with intelephense or it isn't that advanced? I'll give it a shot though. Thanks for the heads-up.
  6. Intellisense has never worked for me with ProcessWire variables :-). It just doesn't pick. I use Felix Becker's. Edit: Aah, I see you use Intelephense. I tried it once but for some reason I cannot remember, I went with Felix's. Maybe I should try it again. Edit 2: I might have gone with PHP Intellisense based on download numbers. I'll try Intelephense and if it works, I'll go with that. I'll leave the Gists up though, for those who use PHP Intellisense.
  7. @AndZyk Attached, a quick and dirty job for Functions API, one for each style. $items = pages("template=basic-page"); style #1 $items = pages()->find("template=basic-page"); style #2 I don't know how style #1 works with (or should even work with) things like pages->count? I know style #2 could be pages()->count. Because of this, VSC will complain of duplicate keys since with the search and replace, we ended up with multiple pages(). (where we had pages->count; pages->find(), etc. :-). I also don't know about the WireArray stuff. I don't think those have functional api, no? They would have to be removed from these snippets. I haven't tested much. If you are able to test, I can upload to separate Gists, once cleaned up, thanks. vsc_pw_functional_api_style-1.json vsc_pw_functional_api_style-2.json
  8. I can make a separate version for Functions API. Looks like a simple regex job Maybe not soon ?.
  9. Yes, you can create your own formatter. Not sure about the learning curve though. Maybe start with an existing extension and build off that. I love notepad++ and use it daily....but not for coding. For text manipulations and a poor man's 'sticky notes', it works for me. But you can't even begin to compare it to VSC. They are two different beasts ?.
  10. I' not sure actually. I've just tried the <?= ... ?> and although they are highlighted, the editor shows a syntax error. <?...?> work OK. I'm not sure if there's an extension to handle the tags you want. I'd still urge you to give VSC a try ?and maybe even ditch those short tags; I've never liked them :-).
  11. ProcessWire API Visual Studio Code Snippets Here is a Gist of all (?) ProcessWire public API snippets for VSC. This is generated from the ProcessWire Cheatsheet. Some stuff needed manual cleanup. I also removed the stuff from the selectors section. I could have missed something, please let me know. Please note this is a complete, well-formed JSON file. If you need to copy to your existing VSC snippets file (most likely your php.json), remember to remove the top and bottom outermost curly braces. One great thing about VSC is that it doesn't care much about typos; fuzzy search will find what you meant to type. E.g., 'cnf' will match 'config'. Maybe the JSON file is too long, I don't know, but sometimes the snippets' descriptions don't show up. The snippets are for use in a template file (i.e., no auto $this->), but you can still use it in a module and/or modify it to suit such needs. Hope you find it useful :-). Demo
  12. Hi @DxJR, Welcome to the forums and ProcessWire. Thanks for testing the module. What ProcessWire version are you using? A recent ProcessWire update seems to have broken the module. I noticed this when setting up some sites last week. I've not had a chance to debug it yet. I am quite busy at the moment and don't know when I'll look into it. Until then, please do not to use the module in production sites. I'll update the first post.
  13. Maybe create a Process Module (say, Manage Users) that only Superusers and Site Admins can view. Create a simple GUI >>> add foo, add bar, etc. Behind the scenes, you use the API to manage users, roles and permissions. Obviously, you restrict the roles, permissions, etc that the Site Admins can manage. It might seem like re-inventing the wheel, but you avoid the red lines/pitfalls you've mentioned (site admins seeing modules, etc). Just my 2p.
  14. OK, I get you. My understanding is that you will have ONE colors page which will hold ALL your colours whereby the different colours are defined within the repeaters? You then want these colours (the ones that are usable) to be individually selectable within page reference field product_color? Meaning your page field will show brown,green,red, etc? Unless I've missed some recent PW feature, you can't do that. Only pages are selectable in page reference fields. So, you would have to change your approach. Let me know if I'm still missing the mark :-).
  15. Hey @jothanne, Welcome to ProcessWire/the forums. I don't get your setup entirely. Do you have a repeater nested within a repeater? i.e., is type_repeater a repeater field that also contains the repeater color_repeater? Normally for the sort of logic you are after (for page fields), you can use the Custom PHP Option (see the input tab of your page field product_color). I'm not sure this solves your problem though as I don't fully grasp your setup.
  16. In future, will the editors, when they create a new project page, be inputting the display title themselves? Yes ? Yes. The defaults are you start from the beginning (0) and you get everything (limit=0 aka, no limit). In my example, I wanted to start from 2 (not a good example, I know) A better example is, assuming I had done a batch before, say the first 100 pages. In the next batch, I'd start from start=101 and limit=100..meaning, I do 100 at a time. There's a way to automate this, but that's a lot more code :-). Not quite. It would work though, but since you want to apply to all projects pages, there is no need to enter a start and limit. The following would do: generateDisplayTitle('display_title','projects'); It should be the name of the template. In my example, it was 'projects'. Adapt to your needs, so yes, 'project' in your case. But it can be any template with a display_title (or whatever you've named the field) field whose pages you need to edit. Test on a local install first ?
  17. I'd leave the title field as is. Names (urls) are generated from the title when you create a page. If your pages are live, then better leave the title as is. How many? This affects how you should run the script below Not a great idea! No need for html here. This is a better way IMO That's why we have the API :-). See script below. TEST BEFORE USE IN PRODUCTION SITE! Log in as superuser Copy and paste the following code into a template file, maybe the one used by your home page. Visit a page using the template in #2 Check if things went OK Delete code from template file when done If you have lots of project pages, make use of the start and limit parameters. /** * Copy title field contents to a specified text field on the same page. * * @param string $fieldName Name of the field to edit. * @param string $templateName Name of the template file whose pages we are editing. * @param integer $start Start of $pages->find(). * @param integer $limit Limit of $pages->find(). * @return void */ function generateDisplayTitle($fieldName, $templateName, $start=0, $limit=10) { // only superusers allowed! if(!wire('user')->isSuperuser()) return; // fetch a limited number of pages $editPages = wire('pages')->find("template=$templateName,start=$start,limit=$limit"); # we found pages if($editPages->count) { foreach ($editPages as $editPage) { $editPage->{$fieldName} = $editPage->title; $editPage->of(false); $editPage->save($fieldName); $editPage->of(true); } } } // call the function - here, we start at index 2 and limit to 3 pages // the field we want to copy content to is called 'display_title' // the template of the pages we want is 'projects' generateDisplayTitle('display_title', 'projects', 2,3); # not many pages use (i.e. do all) #generateDisplayTitle('display_title', 'projects');
  18. Please read the lightbox docs :-). How to achieve this is explained there.
  19. Yes. That's because my example was for single images. I noted as much in my gallery.php code ? For groups/image sets you do it like you now have. Prev/next only work with sets. If using sets/groups, you can delete the $c variable from the script. I have no idea about the odd box error though.
  20. This is because you are not echoing out the gallery at all :-). I see you are using a different template approach from my example (direct output with includes). My approach is delayed output. So, you need to do this in your gallery.php: replace: // append gallery and body markup $content = $gallery; $content .= $page->body; with: // echo gallery and body markup echo $gallery; echo $page->body; That will echo the gallery before the body content. Switch them around if you need to.
  21. Just seen this. Welcome to the forums @Thomas Diroll. It's better (readability, maintenance, etc) to throw the code in a file and call it using the wireRenderFile() method. If using ProcessWire 3.x, you will need to use namespace as follows: return ProcessWire\wireRenderFile('name-of-file');
  22. Any errors in dev tools? Maybe a JS file not getting loaded? Are you using PW 3? Could you please post the full contents of your template file + any other template file it includes? Please post the full markup generated for the gallery Any PHP errors? Do you have ProcessWire debug on? Is the site live or local?
  23. I've tested lightbox2 and it works fine. I am using the Initialize with HTML as per the docs. You don't have to call the script manually on the page unless you are passing options. You will need to set data-lightbox attribute to each <a> element. The following is based on a fresh PW install that uses the _main.php, _init.php, etc, approach, but it should work regardless of your templating approach. _main.php This is where we will output our markup. It is also where we include the CSS and JS for lightbox2 In this example, JS is included in <head>. Move it as you wish. Note the locations of the CSS and JS in this example. Your paths could be different. I uploaded the script's images to /site/templates/images/. This _main.php is the one found here in a ProcessWire install. <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>styles/lightbox.min.css" /> <script src="<?php echo $config->urls->templates?>scripts/lightbox-plus-jquery.min.js"></script> gallery.php I created a template file called gallery.php and a template called gallery. I then created a page that uses this template and uploaded some images. The images field in the template is called images. The contents of gallery.php are below. It is similar to the code in basic-page.php found in this ProcessWire install. If using a different template approach, you can just echo out the value of $gallery, for instance. <?php namespace ProcessWire; // gallery.php template file // Primary content is the page's images gallery $gallery = ''; // if there are images, lets choose them to create an image gallery if(count($page->images)) { $cnt = 1; // if the page has images grab 'em $images = $page->images; foreach ($images as $image) { // create/get image thumbs $thumb = $image->size(150,150); // add image to gallery $gallery .= // @note: unique data-lightbox value! (for single images according to docs) // link to full image "<a href='$image->url' data-lightbox='image-{$cnt}'>" . // image thumb "<img src='$thumb->url' alt='$image->description' /> </a>"; $cnt++; } } else { // no images... $gallery .= '<p>Sorry, there are no images in this gallery</p>'; } // append gallery and body markup $content = $gallery; $content .= $page->body; That's it! If you view the page, you should have a working gallery. Demo
  24. Hi @Roych, How are you building the mobile menu? Is it a separate menu or built on the fly? The usual way to tackle this is to use the Menu Builder's getMenuItems() method to return menu items either as an object or an array which you can traverse using a recursive function to build your menu with your markup and logic as you see fit. Please have a look at this post for examples (including 3 recursive functions you can edit to suit your needs). The functions (somewhat modified) can also be found in this gist. Give us a shout if you run into issues.
×
×
  • Create New...