Jump to content

thetuningspoon

Members
  • Posts

    691
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by thetuningspoon

  1. Hi Wanze, that's what I figured. It doesn't seem like the ideal behavior, though. I don't know enough about how PW works, but it seems like the image should be able to be uploaded without the reference being there before saving. Although my guess is this wouldn't be a trivial thing to change.
  2. I discovered an issue recently, which I haven't seen discussed before. I often use the API to output images directly from image fields without going through the WYSIWYG. When I go to add an image in the admin, I discovered that this image is immediately displayed on the front end, even before I save the page. And if I decide not to save my changes, the image is still saved to the page! This almost burned me a couple times when I uploaded an image just as a demonstration and then later discovered that the image had actually gone up on the site! Is this the intended behavior?
  3. Thank you! Instantiating inside of init() as Soma describes works exactly like I wanted. I'm curious, though.... Why does it work in init() but not in the constructor? Also, thanks for the tip about using fuel. VERY cool. That could come in handy
  4. The reason is that myModule2 could be any one of several modules that implement a basic class template, and I don't want to have to reference the specific module by name in order to make use of it in my code. myModule2 is also closely tied to the functionality of myModule1 and would never be used apart from it. In other words, it's a submodule of myModule1. So I want to be able to reference it generically from within myModule1 and/or within my template by making it a subobject which is instantiated as a property in myModule1 (the specific module used is based on the status of a select box in the admin settings of myModule1). Perhaps this isn't the best way of going about it, but I like the aesthetics of it.
  5. I apologize if this question doesn't make sense... I'm still getting used to OOP. Is it possible to instantiate a module inside of another module? In other words... I would like to be able to create my own API calls like $modules->myModule1->myModule2->myFunction() similar to the ProcessWire core. I figured out how to do this with a generic class by including the class in the module file and instantiating it in the constructor function, but I would like to be able to do it with a module as well (to make installation, etc. more user friendly).
  6. I know the topic isn't really RSS readers, but I just have to express my love for Feedly as well. I was disappointed in losing Google reader at first, but now I'm glad it's gone since it led me to discover Feedly I had always wanted to be able to categorize my feeds by topic. The mobile app is excellent as well.
  7. Thank you Soma, I got it working! Thanks for the clarification.
  8. Well, good for you How would I build this, considering PW doesn't have a native select box field type, and we're dealing with modules instead of pages (so the pages field type seems like an unlikely fit)?
  9. I only briefly looked at the Modules Manager, but doesn't it create a new tab in the admin? I'm thinking of working within the module's basic configuration page. But it sounds like I may be wise to consider adding a tab in the admin for handling the module's various settings. I have some reading up to do on that.
  10. I am experimenting with building a family of interrelated modules where the base module allows you to select which other modules to load. Ideally, I would like to have a select box in the main module's admin settings screen that lists the available modules that are installed and lets you select one of them. Is this possible?
  11. Ok, that's what I thought. I'll probably stick with $_SESSION since it doesn't require the extra steps.
  12. I'm trying to use ProcessWire's $session variable to store multidimensional arrays, like I often do with $_SESSION. I can store multidimensional arrays alright, but if I want to change a variable in one of $session's multidemensional arrays, like so: $session->myArray['one']['two'] = 'foo'; ...I am not able to. Is there any way to do this easily with $session, or am I better off just using php's $_SESSION?
  13. No, my reply was in regard to your first paragraph about being able to identify and delete/edit images easily when using one page per image. Having a grid instaed of just a single column in the admin could be very helpful, I agree.
  14. Actually, kongondo, there's an app... err, module for that too. I dont remember what it's called, but it can show thumbnails next to your pages in the list.
  15. Oh yes, the images don't open in additional browser windows. They open in the current window in a blank page. But I was having a hard time coming up with a way to word that--Fixed. Thanks to all who suggested ImagesManager. I didn't realize that was one of its features, so I'll have to check it out. But it is still an additional module, so I think my point is still at least partially valid
  16. On your fourth question, you can easily implement PayPal's basic standard payment buttons/form into your page's template file, just like you would in any other basic html/php page. If you need something more complex, apeisa's shopping cart module could serve as a basis if you are familiar with php coding, but the payment integration would have to be custom coded. An example would be what my company and I did (except with Authorize.net) on http://www.harkenslandscapesupply.com/ The beauty of ProcessWire is that it makes custom programming relatively quite easy. So if you have an intermediate knowledge of php and look at the API docs you can accomplish pretty much anything and have fun doing it
  17. You're right, that step should be unnecessary. Enabling page numbers should be enough. And yes, the forum editor behaves very erratically sometimes! Glad you found the tutorial to be user-friendly. Thanks for the feedback!
  18. I recently completed a website that had a very large gallery requiring multiple albums (categories) and 100+ images per album with pagination. The solution I developed accomplishes this with just 2 templates (gallery-index and gallery-album) and a single multi-image field for each album, allowing for quick, mass upload of images*. One of the great things about ProcessWire is that you can custom build something like an image gallery with just the tools that the template system and API provide out of the box, without going in search of modules. Once we have the basic templates set up, we will use the excellent FancyBox jQuery script/plugin to add some slick Javascript "lightbox" functionality on top of it. The gallery will still work without FancyBox or with Javascript disabled; it will simply fall back to opening each image in a blank page. So, without further ado... 1. Create a file named gallery-index.php in your site/templates/ folder with the following code. This will be the main page of your gallery. The code simply loops through all of the photo albums that are children of your main gallery page and uses the first image in the album as the cover photo: <? include("./head.inc") ?> <? // Configure thumbnail width/height $thumbWidth = 250; $thumbHeight = 250; // Create an array of the child pages that use the gallery-album template $albums = $page->children('template=gallery-album'); ?> <h2><?= $page->title ?></h2> <div class="gallery"> <ul class="gallery-row row"> <? if(count($albums) > 0) { foreach($albums as $album) { // Grab the first image from the album and create a thumbnail of it $thumb = $album->images->first()->size($thumbWidth, $thumbHeight); ?> <li class="col span4"> <div class="gallery-album photoShadow"> <a href="<?= $album->url ?>" class="gallery-albumThumb" title="<?= $album->title ?>"> <img src="<?= $thumb->url ?>" alt="<?= $thumb->description ?>" /> <h4 class="gallery-albumTitle"><?= $album->title ?></h4> </a> </div><!-- /gallery-album --> </li><!-- /col --> <? } } ?> </ul><!-- /gallery-row --> </div><!-- /gallery --> <? include("./foot.inc") ?> 2. Add the gallery-index template in the ProcessWire admin under Setup->Templates. This template does not require any fields, although you may want to add a body field for outputting additional content to the page. 3. Create a file named gallery-album.php in your site/templates/ folder. This template will be used to both hold and display the images in your albums. Here we will be loading the fancybox plugin as well, so make sure you've downloaded it here: http://fancyapps.com/fancybox/ and uploaded the /fancybox/ folder to your site/templates/scripts/ folder. We are appending the fancybox files to the $config->scripts and $config->styles array before outputting them in our head.inc file so that we're only loading that code on the album pages. So make sure you are outputting those arrays in the <head></head> section of your head.inc file along with your other scripts & styles, like so: <? foreach($config->scripts as $file) { ?><script type="text/javascript" src="<?= $file ?>"></script> <? } ?> <? foreach($config->styles as $file) { ?><link rel="stylesheet" type="text/css" href="<?= $file ?>" /> <? } ?> Please note that you will also have to include jQuery in your head.inc file before your other scripts, if you're not already including it. So here is our gallery-album.php. Notice also that we are calling the FancyBox script and customizing some of its options at the bottom of the file: <? $config->styles->append($config->urls->templates . "scripts/fancybox/jquery.fancybox.css"); $config->styles->append($config->urls->templates . "scripts/fancybox/helpers/jquery.fancybox-thumbs.css?v=1.0.7"); $config->scripts->append($config->urls->templates . "scripts/fancybox/jquery.fancybox.pack.js"); $config->scripts->append($config->urls->templates . "scripts/fancybox/helpers/jquery.fancybox-thumbs.js?v=1.0.7"); // Configure thumbnail width/height & number of photos to display per page $thumbWidth = 150; $thumbHeight = 150; $imagesPerPage = 32; // Make ProcessWire pagination work on the images field (see for full explanation of this) $start = ($input->pageNum - 1) * $imagesPerPage; $total = count($page->images); $images = $page->images->slice($start, $imagesPerPage); // Create a new pageArray to give MarkupPagerNav what it needs $a = new PageArray(); // Add in some generic placeholder pages foreach($images as $unused) $a->add(new Page()); // Tell the PageArray some details it needs for pagination $a->setTotal($total); $a->setLimit($imagesPerPage); $a->setStart($start); include("./head.inc") ?> <?= $a->renderPager() ?> <div class="upOneLevel"><a href="<?= $page->parent->url ?>">← Albums</a></div> <h2><?= $page->title ?></h2> <div class="album"> <ul class="album-row row"> <? if(count($images) > 0) { foreach($images as $image) { $thumb = $image->size($thumbWidth, $thumbHeight); ?> <li class="album-photo darkenOnHover col span3"> <a href="<?= $image->url ?>" rel="fancybox-gallery" class="fancybox" title="<?= $image->description ?>"> <img src="<?= $thumb->url ?>" alt="<?= $thumb->description ?>" /> <!-- Uncomment this line if you want descriptions under images <p class="album-photoDescription"><?= $image->description ?></p>--> </a> </li> <? } } ?> </ul><!-- /album-row --> </div><!-- /album --> <div class="group"><?= $a->renderPager() ?></div> <script type="text/javascript"> $(document).ready(function() { $(".fancybox").fancybox({ prevEffect : 'elastic', nextEffect : 'elastic', loop : false, mouseWheel: true, helpers : { title : { type: 'outside' }, thumbs : { width : 100, height : 60 } } }); }); </script> <? include("./foot.inc") ?> 4. As we did before, add the gallery-album template in the ProcessWire admin. Assign the images field to it, and go into the URLs tab and make sure Page Numbers are allowed. 5. Create a page in the ProcessWire admin for the gallery index using the gallery-index template. You'll probably want to give it a title like "Gallery". 6. Underneath your Gallery page, create child pages that use the gallery-album template, one page for each album you want to create. Name them however you'd like. 7. Go into each album page you created and populate the Images field with your images. Just drag-and-drop. It's as simple as that! If you want to add a description for each image, you can also add it here. If you have more than 32 images (or whatever value you set the $imagesPerPage variable to), the pagination will kick in and split the album into multiple pages. 8. Finally, add in the CSS. The CSS is really up to you, but I'm including a good starting point below. This includes a handy responsive grid system I built for my sites, as well as a .photoShadow class I developed which gives your album covers a cool 3D Polaroid look using pure CSS. /********* Helper Classes **********/ .row:after, .group:after { content: ""; display: block; height: 0; clear: both; visibility: hidden; } .row { ; /* Remove left gutter */ margin-top: 0; margin-right: 0; margin-bottom: 0; padding: 0; zoom: 1; /* IE7 */ position: relative; } .col { display: block; float:left; margin-left: 2%; /* Gutter size */ margin-top: 0; margin-right: 0; margin-bottom: 0; padding: 0; zoom: 1; width: 95.99999999996%; } .span1 {width: 6.33333333333%;} .span2 {width: 14.66666666666%;} .span3 {width: 22.99999999999%;} .span4 {width: 31.33333333332%;} .span5 {width: 39.66666666665%;} .span6 {width: 47.99999999998%;} .span7 {width: 56.33333333331%;} .span8 {width: 64.66666666664%;} .span9 {width: 72.99999999997%;} .span10 {width: 81.3333333333%;} .span11 {width: 89.66666666663%;} .span12 {width: 97.99999999996%;} .photoShadow { position: relative; border: 5px solid #fff; background: #fff; -moz-box-shadow: 0px 0px 2px #ccc; -o-box-shadow: 0px 0px 2px #ccc; -webkit-box-shadow: 0px 0px 2px #ccc; -ms-box-shadow: 0px 0px 2px #ccc; box-shadow: 0px 0px 2px #ccc; } .photoShadow:before { z-index: -1; content: ""; display: block; position: absolute; width: 104%; height: 16px; bottom: -5%; left: -2%; overflow: hidden; border-radius: 50% 50% 0 0; box-shadow: inset 0px 8px 5px #999; } .darkenOnHover { opacity: .8; -webkit-transition: opacity .2s; -moz-transition: opacity .2s; -ms-transition: opacity .2s; -o-transition: opacity .2s; transition: opacity .2s; } .darkenOnHover:hover { opacity: 1; -webkit-transition: opacity .1s; -moz-transition: opacity .1s; -ms-transition: opacity .1s; -o-transition: opacity .1s; transition: opacity .1s; } /********** Blocks **********/ .gallery { } .gallery-album a:hover { text-decoration: none; } .gallery-albumTitle { font-size: 1.1em; text-align: center; margin: .2em ; } .gallery-album { -webkit-transition: all .2s; -moz-transition: all .2s; -ms-transition: all .2s; -o-transition: all .2s; transition: all .2s; } .gallery-album:hover { -webkit-transition: all .2s; -moz-transition: all .2s; -ms-transition: all .2s; -o-transition: all .2s; transition: all .2s; -webkit-box-shadow: 0 0 3px #555; -moz-box-shadow: 0 0 3px #555; -ms-box-shadow: 0 0 3px #555; -o-box-shadow: 0 0 3px #555; box-shadow: 0 0 3px #555; } .album-photo img { margin-bottom: 6px; border: 1px solid #ddd; } .upOneLevel { font-size: 1.1em; margin-bottom: .4em; } .upOneLevel .icon-circle-arrow-left { font-size: 1.5em; margin-right: .4em; } .upOneLevel a:hover { text-decoration: none; } .MarkupPagerNav { margin: 1em 0; font-family: Arial, sans-serif; float: right; } .MarkupPagerNav li { float: left; list-style: none; margin: 0; } .MarkupPagerNav li a, .MarkupPagerNav li.MarkupPagerNavSeparator { display: block; float: left; padding: 2px 9px; color: #fff; background: #2f4248; margin-left: 3px; font-size: 10px; font-weight: bold; text-transform: uppercase; } .MarkupPagerNav li.MarkupPagerNavOn a, .MarkupPagerNav li a:hover { color: #fff; background: #db1174; text-decoration: none; } .MarkupPagerNav li.MarkupPagerNavSeparator { display: inline; color: #777; background: #d2e4ea; padding-left: 3px; padding-right: 3px; } I think that's it! Just make sure you're including the CSS file in your head.inc inside the <head></head> tags and you should be all set. If you come across any issues trying to implement the above (or find any of it confusing) please let me know below. Everyone is coming from different backgrounds and different experience levels. And if you find this tutorial useful, please feel free to let me know as well * I should mention that although it is possible to create galleries in Processwire where each image is represented by its own page (and, as Ryan has mentioned, is often preferable since it is ultimately more scalable), sometimes the ease of using a single image field (which can upload and decompress zip files of images in mass) simply outweighs any drawbacks. If I had to create this gallery with the 1-image-per-page method, it would have taken hours to upload all of the images one-by-one without some sort of additional programming to automate the process.
  19. Ah, I knew there was a reason It would be great if the API did it automatically!
  20. Only 8 minutes later and I have a solution! Using the php function strtotime I can set my date in the MM/DD/YYYY format and have it automatically converted to a timestamp for use in the selector. ... $seasonEnd = strtotime("04/01/$year"); foreach($programs->find("program_start_date<$seasonEnd") as $program) { ... I thought so, but I didn't know how to make one!
  21. If I want to compare datetimes, what format do I need to use in my selector? I'm trying to create a list of child pages that contains only pages with a program_start_date before April 1st. $programs->find("program_start_date<2013-04-1") doesn't work, however. // Get all the child pages that use the program template and sort them by the program start date $programs = $page->children('template=program, sort=program_start_date, sort=title'); ?> <h3>Winter <?= $year ?></h3> <ul> <? foreach($programs->find("program_start_date<2013-04-1") as $program) { ?> <li><?= $program->program_start_date ?> - <?= $program->title ?></li> <? } ?> </ul>
  22. Thanks Soma, I figured it out, but now I'm just a little confused as to why. But I see that now that once the fieldgroup has already been created for the template and assigned to it, I can add another field simply by doing: $t = $templates->get('templateName'); $t->fields->add("fieldName"); $t->fields->save(); Which is much quicker. Is there any way to reorder the fields in a template through the API?
  23. I am trying to create a basic setup script that I can use to pre-populate my new ProcessWire installs with the fields and templates I use on the majority of sites I create. To do this I'm bootstrapping PW in a php file I've created in my site's root: <?php // Bootstrap ProcessWire include('./index.php'); // Assign API variables to make things a little easier $fields = wire("fields"); $templates = wire("templates"); $modules = wire("modules"); // Edit existing fields $f = $fields->body; $f->rows = 30; $f->save(); $f = $fields->sidebar; $f->rows = 30; $f->save(); // Redirect template if(!$fields->redirect_page) { $f = new Field(); $f->type = $modules->get("FieldtypePage"); $f->name = 'redirect_page'; $f->label = 'Link to a Page'; $f->inputfield = 'InputfieldPageListSelect'; $f->save(); } if(!$fields->redirect_url) { $f = new Field(); $f->type = $modules->get("FieldtypeURL"); $f->name = 'redirect_url'; $f->label = 'Link to an off-site URL'; $f->noRelative = 1; $f->addRoot = 0; $f->placeholder = 'http://www.website.com/'; $f->save(); } if(!$templates->redirect) { $t = new Template(); $t->name = 'redirect'; $t->fields->add("redirect_page"); $t->fields->add("redirect_url"); $t->save(); } echo 'Default setup is complete!'; Everything seems to work except for the last bit on the bottom where I try and assign the fields to the new "redirect" template. I get the error message "Error: Call to a member function add() on a non-object" I know it's probably something simple, but I can't figure it out! Any ideas? Edit: As usual, I figure out my problem as soon as I post my question on the forums Here is the working code: <?php // Bootstrap ProcessWire include('./index.php'); // Assign API variables to make things a little easier $fields = wire("fields"); $templates = wire("templates"); $modules = wire("modules"); // Edit existing fields $f = $fields->body; $f->rows = 30; $f->save(); $f = $fields->sidebar; $f->rows = 30; $f->save(); // Create redirect template & fields $newTemplateName = 'redirect'; if(!$fields->redirect_page) { $f = new Field(); $f->type = $modules->get("FieldtypePage"); $f->name = 'redirect_page'; $f->label = 'Link to a Page'; $f->inputfield = 'InputfieldPageListSelect'; $f->save(); } if(!$fields->redirect_url) { $f = new Field(); $f->type = $modules->get("FieldtypeURL"); $f->name = 'redirect_url'; $f->label = 'Link to an off-site URL'; $f->noRelative = 1; $f->addRoot = 0; $f->placeholder = 'http://www.website.com/'; $f->save(); } if(!$templates->$newTemplateName) { $fg = new Fieldgroup(); $fg->name = $newTemplateName; $fg->add("title"); $fg->add("redirect_page"); $fg->add("redirect_url"); $fg->save(); $t = new Template(); $t->name = $newTemplateName; $t->fieldgroup = $fg; $t->save(); } echo 'Default setup is complete!'; I am still unclear on what a Fieldgroup is and why I need to create one in order to make any changes to the template's field assignments. It feels like a bit of a clumsy extra step to have to go through because it doesn't seem to have any representation on the PW admin interface. I'm sure there's a good reason for it, though, knowing Ryan.
  24. How do I get access the FormBuilder forum? I purchased a license, but didn't see anything about how to access it. Maybe because I used a different email address than on this forum? Anyway, I have a question about how I might be able to integrate the form with a payment processor (probably just PayPal). Basically, all I need is a way to gather all of the value attributes from all of the selected radio buttons in the form and add them up into a single input element (total price) that can then be posted to an outside URL (set in the formbuilder settings). I've been trying to do this using jQuery, but I think that the fact that the form is in an iframe may pose an issue. I haven't worked a lot with iframes, but my guess is that the form submission isn't going to post any values from outside of the iframe... Am I right? Edit: Oops, especially since the form tag is inside the iframe... Yeah, that definitely won't work, at least not using the embed method. Not sure if this topic has come up already. Maybe someone has developed a better solution for it. Edit: Oops again... I'll PM Ryan about the support form.
×
×
  • Create New...