Jump to content

kongondo

PW-Moderators
  • Posts

    7,479
  • Joined

  • Last visited

  • Days Won

    146

Everything posted by kongondo

  1. Wish: Nico, maybe remove the closing PHP tag in the generated file? Thanks
  2. Nice one Nico! Moved this to 'dev' instead....in fact don't know why it is off-topic at all? Better in Module/Plugin Development?
  3. I suppose you can, given that the module is still in Alpha. You would then make an announcement here (and especially in your first post). I would also recommend you polish up the readme a bit ....just a little bit about what the module does (I know we 'all' know about captcha...but nice touch to say what your module does all the same). Thanks!
  4. Naming Conventions: Have a look at these: https://processwire.com/talk/topic/2394-how-to-present-your-module/ http://processwire.com/api/modules/ That is what Horst meant by: Note though that the class name still has to be...ClassName..., i.e. just the way you've named yours.. Directory structure... ....should be fine. PW will automatically create a directory named after the module class (ProcessMakeCoffee) when that module is installed if you've submitted it to the modules' directory. Otherwise, the normal instruction is for your users to create the directory if manually installing the module....Have a look at the GitHub project pages of some of the modules in the modules' directory..e..g. https://github.com/ryancramerdesign/FieldtypeEvents https://github.com/somatonic/MarkupSimpleNavigation https://github.com/horst-n/WireMailSmtp
  5. @markoj, Glad you got it sorted. Yes, MB caters for some very specific needs. Btw, if you haven't seen it already, there is an intro to PW for those with a similar CMS background to yours
  6. @markoj, You can pass attribute=value pairs to HC. There is a nice example here: https://processwire.com/talk/topic/1182-module-image-tags/#entry40015 In my example, I assumed you were including 'Blog' as an external page. There is an option in MB to open external links in new tabs if you insist on using it OK, back to your question...In the following example, we pass a title to HC to find a page with that title and return its first image from an image field called 'gallery_preview_image'. To test this, use this code to import the HC code....(see the import button when viewing your list of HCs). !HannaCode:images:eyJuYW1lIjoiaW1hZ2VzIiwidHlwZSI6IjIiLCJjb2RlIjoiXC8qaGNfYXR0clxucz1cIlwiXG5oY19hdHRyKlwvXG48P3BocFxuXG4kc2VsID0gJHMgPyBcInRpdGxlPSRzLCB0ZW1wbGF0ZT1tZW51X2ltYWdlXCIgOiAnJztcblxuaWYgKCRzZWwpIHtcblxuICAgICRwID0gd2lyZSgncGFnZXMnKS0+Z2V0KCRzZWwpO1xuICAgICRpbWFnZSA9ICRwLT5nYWxsZXJ5X3ByZXZpZXdfaW1hZ2UtPmZpcnN0KDApLT51cmw7XG4gICAgJGltYWdlID0gXCI8aW1nIHNyYz0nJGltYWdlJz5cIjtcblxufVxuXG5lbHNlIHtcblxuICAgICRpbWFnZSA9ICcnO1xufVxuXG5lY2hvICRpbWFnZTsifQ==/!HannaCode That should give you code like this (plus populate your HC's attributes field in the Basics tab with s) <?php $sel = $s ? "title=$s, template=menu_image" : ''; if ($sel) { $p = wire('pages')->get($sel); $image = $p->gallery_preview_image->first(0)->url; $image = "<img src='$image'>"; } else { $image = ''; } echo $image; Then, in your MB pass your menu item's page's titles to HC like so: I haven't included your 'Blog' page in this example but you can do that easily. However, irrespective of whether it is an external (i.e. non-PW page) or internal, its image will have to live somewhere on your site.
  7. Well this is simply not true. You use $page for getting the current page and $pages for getting any other page(s)...
  8. I suggest you carefully study and bookmark/reference this table. It is an invaluable reference that will teach/remind you when to use/not use isset, empty, is_null, etc.. PHP type comparison tables http://php.net/manual/en/types.comparisons.php As for you image, I think I already answered you question but I'll repeat it here: If it is a single image field [an image field with a maximum files allowed of 1] if($page-img) {} if it is a multiple image field [an image filed with maximum files allowed of 0 or > 1, even if it contains only one image in your page] if(count($page->img)){}
  9. If field can contain only one value or a string... if($page->title) echo $page->title; If field can contain multiple values, e.g. a multiple image field or multiple page field (i.e. contain arrays) if(count($page->images)) echo "we have images. Let's foreach them"; https://processwire.com/talk/topic/2239-how-to-test-for-empty-fields/ https://processwire.com/talk/topic/546-how-to-detect-an-empty-field/ https://processwire.com/talk/topic/8067-cant-detect-empty-field/ https://processwire.com/talk/topic/957-how-to-find-elements-with-empty-field/ https://processwire.com/talk/topic/8850-check-if-a-datetime-field-is-empty-does-not-work/ https://processwire.com/talk/topic/4177-checking-for-empty-textarea-field/ https://processwire.com/talk/topic/3050-checking-for-a-field-if-else/ etc....
  10. Has Raymond's technique been submitted to the PW Recipe's yet?
  11. There you go...two for the price of one
  12. Hi markoj, First welcome to PW and the forums! Yes, that's possible. MB allows you to 'allow HTML in menu items title'. See that option when editing your menu under the tab 'main'. You would need to be a superuser or have the permission 'menu-builder-allow-markup' in order to set and use that option. Secondly, your 'Ditto' in this case would be Hanna Code: https://processwire.com/talk/topic/3745-hanna-code http://mods.pw/4b Install the module. Otherwise, if you included your whole HTML in your menu item's title in MB, it won't look pretty and the HTML will be rendered. The <h1> would be especially ugly there .. I don't know where your images will be coming from but in this example, I assume they are saved in some page with an image field called 'img' OK, once you've installed HC module (taking care to follow all the instructions, create a Hanna Code of type PHP. Let's call it 'test'. Add the following code to it. This is just example code; $p = wire('pages')->get(1317); #$out = $p->img->first()->size(0,50)->url; $out = $p->img->eq(0)->size(0,50)->url; $out = "<img src='$out'>"; echo $out; Here we assume your images are stored in a field called 'img' and that field allows multiple images. We assume that field is populated in a page with ID 1317. We are also grabbing the first image and resizing it. Save the HC. Head over to MB (assuming you've installed the module). Create a menu and enable 'allow HTML...' as I described above. Add at least one menu item to your menu. Enter something the below in your menu item's title. We assume the title is called 'Blog'. [[test]]<span>Blog</span> Here we use span for convenience, otherwise <h1> will be rendered in the menu title drag and drop handle (hacky I know). We'll replace the <span> with <h1) at runtime. In your template file you could render your menu as follows: //get MB $menu = $modules->get('MarkupMenuBuilder'); $out = $menu->render('My Menu Title', $options);//holds rendered menu //get hanna code $hanna = $modules->get('TextformatterHannaCode'); //render the [[test]] HC + replace <span> with <h1> echo $hanna->render(str_replace('span', 'h1', $menu->render($m, $options))); See MB's documentation about what you can pass to $options (e.g. you may not wish to use <ul> and <li> in your menu. This is just a quick example. Maybe things could be done better.. ....And you probably want to edit this menu yourself...clients will probably be confused with [[test]]Blog
  13. Update: version 0.0.9 Fixed the issue whereby 'current_class_level' was not being correctly applied in cases where 'current_class' is applied beyond included children into native MB menu items. In dev branch for now.
  14. I always use bundle version - I view the whole thing as one package and also don't want to confuse users...In my commit I enter notes to specify if a version bump 'was just to keep up with updated module xx'. But am not saying this is the 'correct way'
  15. Pete would definitely know...so let's wait for his input
  16. So in Full Editor you don't see this?
  17. Nope...works with new topics as well. See my test here: https://processwire.com/talk/forum/11-pub/ https://processwire.com/talk/topic/9632-testing-forum-prefixes/ Edit Deleted test
  18. Maybe...tried with Blog and now it works...
  19. I've tried this before as well, and it didn't work...gave up quickly ...
  20. Thx for this Kixe.Looks like a tutorial to me. Shall I move it there?
  21. Quick heads-up I have been forgetting to mention. This discussion reminded me about it. There are cases where you need 'dummy links', 'divider menu items', 'non-clickable menu items', etc, You can easily achieve that by creating 'External Menu items' and assigning # as the URL.
  22. You are right...would certainly make life easier....Just Create a 'dummy link' and bob's your uncle.... ...I could then focus on other pending modules
  23. Currently this is possibly only with Custom Menu Item (external links) where you can provide # as a URL. At the moment, PW pages' URLs are non-editable but I can easily provide an option to make them editable if such a feature was requested (preferably via Github)..
×
×
  • Create New...