Jump to content

diogo

Moderators
  • Posts

    4,296
  • Joined

  • Last visited

  • Days Won

    79

Everything posted by diogo

  1. diogo

    Hanna Code

    I posted my first Hanna Code here http://processwire.com/talk/topic/1182-module-image-tags/?p=40015
  2. One other immediate solution is to use Ryan's Hanna Code. I adapted the module to Hanna code, and it seems to be working pretty well, although the tags are a bit different: {fieldname:2} and [[images f="fieldname" n=2]] It looks a bit more complicated at first, but it's not really. Here is a resumed explanation: defaults: [[images p="0" f="0" n="0"]] where p is the page number, f is the field name and n is the image position on that field. The above is equivalent to simply: [[images]] And it will get all the images from the first field of the "image" type on the same page of this Hanna Code field. Because: if $p="0"; // $p will hold the $page object if $f="0"; // $f will hold the first images field found on $p if $n="0"; // $n will echo all the images from $f From here you can have any combination: [[images n="4"]] // echoes the image on the forth position of the first image field of this page [[images p="1" f="myimages"]] // echoes all the images of the field "myimages" in the homepage That's it. Here is the string to import this Hanna Code: !HannaCode:images:eyJuYW1lIjoiaW1hZ2VzIiwidHlwZSI6IjIiLCJjb2RlIjoiXC8qaGNfYXR0clxucD1cIjBcIlxuZj1cIjBcIlxubj1cIjBcIlxuaGNfYXR0cipcL1xuJG15UGFnZSA9ICRwID8gJHBhZ2VzLT5nZXQoJHApIDogJHBhZ2U7XHJcbiRmaWVsZE5hbWUgPSAkbXlQYWdlLT5maWVsZHMtPmdldCgndHlwZT1GaWVsZHR5cGVJbWFnZScpO1xyXG4kbXlGaWVsZCA9ICRmID8gJG15UGFnZS0+JGYgOiAkbXlQYWdlLT4kZmllbGROYW1lO1xyXG5cclxuJGluZGV4ID0gJG4tMTtcclxuXHJcbmlmKCRteUZpZWxkIGluc3RhbmNlb2YgUGFnZWltYWdlcyl7XHJcbiAgICBpZigkbil7XHJcbiAgICAgICAgJGltYWdlID0gJG15RmllbGQtPmVxKCRpbmRleCk7XHJcbiAgICAgICAgJGltYWdlID0gXCI8aW1nIGNsYXNzPSdJbWFnZVRhZ3MnIHNyYz0nJGltYWdlLT51cmwnIGFsdD0nJGltYWdlLT5kZXNjcmlwdGlvbic+XCI7XHJcbiAgICB9IGVsc2Uge1xyXG4gICAgICAgICRpbWFnZSA9IFwiXCI7XHJcbiAgICAgICAgZm9yZWFjaCgkbXlGaWVsZCBhcyAkaW1nKXtcclxuICAgICAgICAgICAgJGltYWdlIC49IFwiPGltZyBjbGFzcz0nSW1hZ2VUYWdzJyBzcmM9JyRpbWctPnVybCcgYWx0PSckaW1nLT5kZXNjcmlwdGlvbic+XCI7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG4gICAgXHJcbn0gZWxzZSBpZigkbXlGaWVsZCBpbnN0YW5jZW9mIFBhZ2VpbWFnZSl7XHJcbiAgICAkaW1hZ2UgPSBcIjxpbWcgY2xhc3M9J0ltYWdlVGFncycgc3JjPSckZmllbGQtPnVybCcgYWx0PSckZmllbGQtPmRlc2NyaXB0aW9uJz5cIjtcclxufSBlbHNlIHtcclxuICAgICRpbWFnZSA9IFwiXCI7XHJcbn1cclxuXHJcbmVjaG8gJGltYWdlOyJ9/!HannaCode
  3. I just realized that there is a problem with the module. If you echo a field that has this textformatter from another page, it will look for the images field on that other page. echo $pages->get(123)->imagetagsfield; This is so obvious, but didn't even cross my mind... problem is, textformatter modules receive a simple string to work upon, so they are not aware of what page it comes from, and this module uses "$this->page" to look for the field, so, the page from where it is called, and not the page where it is from. Ideas are welcome Edit: I found an immediate solution, but only for Processwire's DEV version. It's not the ideal for sure, so I'm still wanting ideas: Create a new php file (name it .php or .inc, or whatever you want. I named mine imagetags.php and put it inside a "renders" folder) and put this code on it: <?php echo $page->imagetagsfield; On the template do this instead of the first code from the post: echo $pages->get(1001)->render('renders/imagetags.php');
  4. I agree. Maybe we could manage to make the docs on the website semi-collaborative by creating a "docs collaboration" forum, from where some things would be added to the website after discussion and approval. People seem to be much more active here than in the comments on the website.
  5. in the templates list page, on top. open 'filters' and choose 'show system templates', the users template will be shown.
  6. Copy the website to a local server and do the switch. If everything goes well, apply it on the server.
  7. I confess I didn't think of this when I created the module... Thanks for finding it I already corrected it on github, but if you don't want to download it again, just add these changes to the module file: static public function getModuleInfo() { return array( 'title' => 'Admin Custom Pages', 'summary' => 'Create custom admin pages without building a Process Module', 'version' => 105, // <-- change the version number 'author' => 'Diogo Oliveira', // <-- add this comma 'permission' => 'page-view' // <-- add this line ); } This gives permission to anyone to use the process, but you still can control the permissions for the pages in their templates. Edit: kongondo, he means the process itself. Even if the page is viewable by the user, the process wouldn't run, and throw that message.
  8. Hm, there are several things to correct in your code. First one, and most important, is that slice() will give you only one array and I don't think this is what you are looking after. Second one, is the way you are using the => sign in your foreach. When you do "$slicedarticle => $total", what will happen is that $slicedarticle will be populated the key of this element, and $total will be the value of the element. So, the content that you had on these variables will simply be lost. Read here http://php.net/manual/en/control-structures.foreach.php What I interpret that you want, is to create the amount of slides needed so you have only three elements on each slide. Is that right? If so, try this: $items_per_page = 3; $myPages = $pages->get(1)->find('sort=sort'); $nrSlides = count($myPages)/$items_per_page; while($nrSlides > 0) { echo "<div class='slide'>"; for($i=$items_per_page; $i>0; $i--) { if(count($myPages)) { $article = $myPages->shift(); echo "<h3>{$article->title}</h3><p>{$article->id}</p>"; } } echo "</div>"; $nrSlides--; } Edit: By your new explanation, I think this is what you want Also, look for shift() on the cheatsheet http://cheatsheet.processwire.com/ to understand what's happening in my code: Edit2: changed the if statement in the code for something better
  9. It's strange that it outputs nothing. It should output the page ID. To output the title, for instance, you would do this:
  10. Hello ideagonal, welcome to the forum! My guess is that the field that you are trying to output is a multiple images field. Try this, and you'll see it will work: echo "<img src='{$page->featuredImg->first()->url}'>"; What I did there was output explicitly the first image in the array. But if you are planning to have only one image on that field, the best would be to limit it to 1 in the field option. This will transform this field in a single image field, which would work straight with the code you used. For how to use multiple images, read this: http://processwire.com/api/fieldtypes/images/
  11. Great mood for focusing on work http://www.rdio.com/artist/Marc_4/ (sign up on rdio to listen)
  12. Ryan, since some of us are using the inline mode on admin pages, wouldn't it make sense that the purifier is not required at all? Maybe mentioning it on the field options would be enough.
  13. Sure, just go to "Profile" and set the new password.
  14. If you only want to move the website, you don't need to run the installer again. All you need is to import the database, move the files to the server, adjust the necessary permissions if needed, and update the database permissions on the config file. Edit: Oh, I didn't see your last post. Sorry that I understood what you wanted wrongly. I thought you were doing some weird experiment
  15. hm, I'm not sure what you are trying to do. But the error message comes from this line in the installer: if(is_file("./site/assets/installed.php")) die("This installer has already run. Please delete it."); ...so, I guess you would have to remove that file from the assets folder.
  16. You don't have to point the browser to the installer. Look, this is the line in index.php that decides if the installer should be run: if(!$config->dbName && is_file("./install.php") && strtolower($_SERVER['REQUEST_URI']) == strtolower($rootURL)) { require("./install.php"); exit(0); } So, if there isn't a $config->dbName property yet, and the install.php file is there. You will get to the installer. So, that error message doesn't have anything to do with you calling the index instead of the installer. Can you confirm in your config.php file if you have a $config->dbName directive? Edit: anyway, you can always just replace the content of the config.php file buy the original content and delete the db table and create another one.
  17. Here is a pretty simple and balanced calculation: ( Likes / Posts ) * Likes You should try to stick with likes and post, everything else is noise. If you try to do something very accurate you will be giving to much importance to something that it's not more than a fun thing to do. If you want you can give some extra points. Here are some suggestions: niknames that start with "d": multiply the result by 2; avatar with lots of white space: 400 extra points; no signature: 500 extra points;
  18. And the time that people hesitated when giving the like. Do we have that info?
  19. I was on mobile, so the answer was a bit dry. Thanks for completing it Pete. And welcome to the forum Ollie
  20. on the image src you have the child url, when what you should have is the thumbnail url.
  21. The blog profile has an archive. Did you look there?
  22. I must confess I'm pretty confused by that math, can you explain the intention? Is it some kind of known and tested formula? Edit: the only truly fair formula is one where Ryan stays on the top
×
×
  • Create New...