-
Posts
691 -
Joined
-
Last visited
-
Days Won
6
Everything posted by thetuningspoon
-
Is it possible to select a page by the person who created it? I tried find("createdUser.name=$userName") but that doesn't seem to work.
-
This is common when going in and out of php while coding. When doing this you can avoid having to use echo/print. For example: <?php if($foo = $bar) { ?> <p>Show this text and this <?= $variable ?>.</p> <?php } else { ?> <p>Show this text instead with this <?= $otherVariable ?>.</p> <?php } ?> I like to keep my open and close php tags on separate lines to keep them out of the way so they don't mess with my indentation. But you'll see here that the same <?php } ?> tag appears at the bottom to close out the if/else statement. I prefer to code this way because it puts the markup (html) first rather than the php. And you can avoid having to put all of your html in quotes and using escape characters or single quotes where you have conflicting quotes in your html. Plus indentation is easier, and is preserved when you view source later on. I use the shortened <? tag instead of <?php to make it even cleaner (although I've heard some servers don't like that-- I haven't run into any issues yet).
-
Assigning Fields to Repeaters with the API
thetuningspoon replied to thetuningspoon's topic in API & Templates
I think that will do it. -
Thanks so much pwired
-
PhotoWebMax, I think your post is very perceptive. ProcessWire appeals very much to people who are both designers and developers. It also works well for teams who divide up those responsibilities. However, it doesn't make any attempt to do development for you (like Joomla or WordPress might, for example). Having said that, what it does do is reduce the learning curve on the development side as much as is possible without sacrificing capabilities or imposing limitations on what can be done with it. I started ProcessWire as a designer too, so you're in good company. Most of my sites were not built on CMSs because I could never get the big ones (Joomla, Drupal, or WordPress) to do what I wanted, or to do it in a way that would be intuitive for my clients to manage. Anyway, the only php experience I had was using includes in my regular html sites (and whatever I could remember from the one or two non-php-based programming classes I had taken). What really drew me to PW was that I could continue making sites exactly the way that I always had-- writing all my own html, css, and choosing when and where to break up my code into external includes. And I didn't even have to learn a new syntax for that, since it was all php-based. From there, it was just a matter of learning how to grab the data from the CMS that I needed to be dynamic and putting it into my template files with the API. Going through this process opened me up to the world of development. I won't say that it was easy (or that I don't still have a lot to learn), but for me PW made programming fun and intuitive, and actually seem attainable for a design-minded person like me. And by spending time on these forums and asking a lot of questions, I was able to get up and running with the basics right away and then learn the more complex stuff from there. Now that you've described what you're trying to do with having galleries as a part of multiple templates, I do believe you have a good approach for your use case. Please don't get hung up on my way of doing things. Do what makes sense to you and will be easy for you to manage. If that means loading the scripts on all pages and sacrificing a tiny bit of page load speed, then do that. Heck, if repeating the code in every template file and not using includes at all makes it easier and gives you the more granular level of control that you need, then do that. I only looked at MODx briefly before I found PW, so I can't speak to the similarities and differences. But I will say that once I finally found PW I haven't looked back
-
Ok, let's back up a bit Can I ask why you're separating everything out into includes in your template files? Unless you're going to be reusing the code in other templates (as with the head, sidebar, and foot), breaking everything out is unnecessary and may be contributing to some of the confusion here. Anyway, I think what's happening here is that you're getting confused by this bit: $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"); This is just a way of creating an array (list) of the scripts and css files particular to one template without having to change the code inside of head.inc (this is so the scripts will only load when they're actually needed). The reason why this comes before the head.inc file is that the list is actually output inside of the head.inc file (you may want to go back and re-read that part of my tutorial), so the array has to be built before that. This is the logic in the head.inc file that actually takes the arrays and produces the links from them: <? 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 ?>" /> <? } ?> In retrospect, I should have left this out because it is really too confusing for beginners. But you can always remove the arrays and just link the css files and scripts directly in the head.inc file the same way that you link your other scripts and css files. But you must make sure that each script is in the correct order. In Javascript, if one script references a function or a variable from another script, that script must precede the current script in the document flow. So your jQuery must always be loaded first in head.inc. It is good practice in web programming to separate out your logic (php) from your markup (html) as much as is possible/reasonable to do. So that, along with the need to create the script/css arrays BEFORE they are output inside the head.inc file is the reason why head.inc was not loaded at the top of gallery-album.php. So when you moved head.inc above gallery-album.inc without moving the arrays too, you disrupted the program flow. In regard to the CSS classes: These aren't part of a template, but part of a layout system I created for my own projects to speed development. The only class here required to make the gallery work functionally is the "fancybox" class. All of the rest can be removed or replaced as you see fit, but you will lose the grid layout (assuming you attached the css I provided to go along with it in the tutorial) and will have to rebuild it. Hope some of that made sense...
-
Do you have any other javascript running on the page, or did you add any additional scripts? Make sure that your jQuery is being loaded before the fancybox script and any other javascript code. In cases like this I usually make generous use of edit > undo until things start working the way they were before and then I make note of what may have changed. If you have a public link I'd be happy to look at it.
-
That's strange. It definitely should work...
-
There are a few different approaches you could take. How are you generating your menu? If it's with Soma's plugin, you can limit the number of page levels with the settings (see the plugin documentation). This is usually the approach I take since I don't ever go more than 2 levels deep on my menus. If that won't work for your use case, I believe you can also exclude by template in the plugin settings. So in that case you would add gallery-album to the excluded template list. You can also exclude by template if you are writing your own menu logic. Another approach would be to make the album pages hidden and then add include=hidden to the children selector (although the downside is that you have to remember to set the page to hidden for every new album): Change this: $albums = $page->children('template=gallery-album'); To this: $albums = $page->children('template=gallery-album,include=hidden'); A third way would be to have all of the albums in a different (hidden) part of the page tree so they are separated entirely from your menu structure, but that would involve a bit of code tweaking. There are probably other ways too... Hope that helps!
-
Great, glad it's working for you!
-
Hi Alan, the reason why you have to use eq() is that your images field is set to accept multiple images. You should set the image field to accept only 1 image and then it will work. So "images" probably isn't the best name for the field, but you get the idea
-
Hey Alan, thanks for the kind words. If I understand correctly what you're asking (making an album where each image is stored in its own child page along with other metadata), then that is actually simpler than what I've done here since we don't need to "fake" the pages--they already exist. Here's what the gallery-album.php would look like: <? $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; $images = $page->children("limit=$imagesPerPage"); include("./head.inc") ?> <?= $images->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->images->size($thumbWidth, $thumbHeight); ?> <li class="album-photo darkenOnHover col span3"> <a href="<?= $image->images->url ?>" rel="fancybox-gallery" class="fancybox" title="<?= $image->images->description ?>"> <img src="<?= $thumb->url ?>" alt="<?= $thumb->description ?>" /> <!-- Uncomment this line if you want descriptions under images <p class="album-photoDescription"><?= $image->$images->description ?></p>--> </a> </li> <? } } ?> </ul><!-- /album-row --> </div><!-- /album --> <div class="group"><?= $images->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") ?> Where "images" is the name of the image field on your child pages. I haven't tested this yet but it should work. You can then use $image variable anywhere within the loop to access your other metadata fields.EDIT: Just corrected a stupid mistake. This should work now!
-
Ok, let me know if you have any questions.
-
Ah yes, multiple jQueries is a common pitfall to watch out for! Congratulations on your success--glad I could help! I know that learning the basic php needed for template customization can be a bit challenging at first, but you'll quickly discover how much power it gives you. Most CMSs use some sort of templating language that you have to learn anyway, but using php for templating allows you to carry that skill elsewhere. If you keep at it you'll be a php pro in no time
-
The paths all look correct, although you are including the script twice (the fancybox.pack.js and the unpacked fancybox.js) You only need one of them (it is the same thing, just compressed vs. uncompressed), and having both may be causing a problem. Like I mentioned earlier-- If that doesn't work, take a look at the "console" in your browser's developer tools and see if it has any errors in it. It will tell you if there are issues linking files or if you have javascript errors.
-
I think I am using version 2, while the PW core version is version 1. Nowadays I've started using the Magnific popup instead. Feel free to use whatever lightbox you'd like--you'll just have to tweak the paths, javascript call, and any necessary classes in the html.
-
A 404 means that the page doesn't exist, so it won't be indexed and it won't be visible, which is exactly what you want. So a page with a template with no template file is the way to go for sure.
-
No, that shouldn't be a problem. That's just because your installation is in a subfolder. Glad you are having better luck this time. Did you download the Fancybox script (http://fancyapps.com/fancybox/), unzip it, and add it to the /sites/scripts/ folder? You will have to make sure the folder is named "fancybox" as well to match the path I used. If still no luck, take a look at the "console" in your browser's developer tools and see if it has any errors. It will tell you if there are issues linking files or if you have javascript errors. Actually, this is not loading from the module-- it's just using the $config->styles and $config->scripts arrays. Once the arrays are populated at the top of the template, they are looped through in the header include.
-
FYI, I just updated the code to check for the presence of albums and images before outputting anything.
-
Hi PhotoWebMax. The error you're getting is where the first image from each album is grabbed to create an album thumbnail. Since I don't have any error checking here (oops) I think you might get this error if you have no albums, have empty albums, or your albums aren't using a template with the name gallery-album (as described in my setup instructions). To be sure, I'd need to see the site you're working on. Here is a site that uses this gallery system: http://www.maranathafamilyministries.org/photo-gallery/
-
An almost MVC approach to using templates
thetuningspoon replied to larrybotha's topic in API & Templates
This looks very cool and well thought out, but I'm wondering... Is there an advantage to having your controller code in a separate file rather than just putting it at the top of your template? Since the code is applicable to just one template, I don't see the advantage of putting it in a separate file. This whole MVC inside of MVC is kind of confusing me. Doesn't PW also already provide you with a way of adding new controller logic through creating modules? -
Thoughts on prototyping/wireframing software
thetuningspoon replied to onjegolders's topic in Dev Talk
Another Bohemian Sketch user here. I've tried to become more iterative in my design process, but I always end up going back to just playing around with fonts, colors, and shapes in Sketch/Fireworks/Inkscape until something good starts to take form. Sketch is particularly good at facilitating this 'freeform' process. As long as I've done enough research with the client beforehand to know their needs, audience, and message, this seems to work out well. I think the wireframe stage becomes much more important when working on interactive apps, whereas it is less important for traditional marketing websites.- 38 replies
-
- 1
-
- software
- prototyping
-
(and 1 more)
Tagged with:
-
New ProcessWire admin theme on dev branch
thetuningspoon replied to ryan's topic in Themes and Profiles
Oh Soma, ever so humble... -
I once had a marketing company tell me that they did a logo for a client of mine they had done some collateral for, when it was actually I who designed the logo. It went something like this... Me: "Oh yeah, I like the collateral you did for them. We've done work for them as well. We designed their logo, actually." Marketing: "Yes, that's right. We did their logo and all their collateral."
-
FontAwesome template icons not showing in page list
thetuningspoon replied to thetuningspoon's topic in General Support
I figured it out. It was a conflict with the Page List Image Label module. It's an older version so Soma may have fixed this already. I'll try upgrading it.