Jump to content

Joss

PW-Moderators
  • Posts

    2,862
  • Joined

  • Last visited

  • Days Won

    47

Everything posted by Joss

  1. That is just bracketing the loop up. "For Each of the Following items in an array do something until the array runs out." When you create an images field, unless you set it to only allow one image, it will always be an array of images. If you have added three images to the field you will have an array of three images and all the details about those images. In this case, we want the file name and the path to where it is kept. So, $page->slide_images retrieves the entire array, and we want to split that up into bits and put each bit of it into a variable called $image. Now we can get at the individual elements - $image->url will give the path and file name for the first image in the array. Then it hits the closing curly bracket which tells it to go back to the start and do the trick with the next item in the list. It will do that three times, since that is how many images we have loaded into our field. In music, it would be a coda :|| Personally, if that was used instead I would be much more comfortable! Though I am not sure what the coding equivalent of "repeat until fade" would be. There you go - I fancied writing out an overly long answer. It has been one of those days!
  2. Hi Panictree Yes, I tend to agree with you, but Luis pointed out that this limitation is actually to make touch devices easier to use where you have to differentiate between touching to open and touching to link. So, whatever system you use, you need to have the parents open something rather than link to something, just to make it usable. In the meantime, I am just stuck with finishing off the menu system before I add it to the modules: http://processwire.com/talk/topic/2690-volunteer-needed-to-help-sort-menu/
  3. Ah, I assume you are using the DEV version? Those tags are simply for sorting the field list in the admin. You will notice the templates have the same thing. If you put something like "common" in one of them, when you go back to the fields list you will see it is now divided into "common" and "untagged" I am not certain how to achieve what you want - but it will be possible. Just needs someone with more knowledge than me!
  4. Oh, gawd.... its one of my Bootstrap moments again! I have been pretty determined to do a better version of my boostrap menu markup - and, well, THAT was a steep learning curve! And for the most part I have got there. The bootstrap menu has an issue - it tends to change class names as you go down the list! So, the UL has the class dropdown-menu (and all the lower ones do too) <li> that has no child has no class name but <li> that have children have the class dropdown. <a> That trigger the drop down have a ton of stuff And <li> that are children of the original <li> and have children get the class - dropdown-submen. Here is a rendered example from one of my demos (you can tell its mine because the words Food and Bar appear in it) <ul class="nav"> <li class="active"><a href="/">Home</a></li> <li><a href="/food/">Food</a></li> <li><a href="/the-bars/">The Bars</a></li> <li><a href="/news/">News & Events</a></li> <li class="dropdown open"><a class="dropdown-toggle" data-toggle="dropdown" href="/about/">About<b class="caret"></b></a> <ul class="dropdown-menu"> <li class="dropdown-submenu"><a href="/about/about-us/">About Us</a> <ul class="dropdown-menu"> <li><a href="/about/about-us/about-us-1-2/">about us 1 - 2</a></li> <li><a href="/about/about-us/about-1-1/">about 1 - 1</a></li> </ul> </li> <li class=""><a href="/about/about-us-2/">about us 2</a></li> </ul> </li> </ul> Now, I am very please to say that I have come up with a nice new clean version of the code that does the above. But it only goes as far as the first set of sub-menus. In theory you can keep adding sub-menus to sub-menus till you break the browser, but I don't know how to write it so that from where the sub-menu starts, it keeps rolling out children and grandchildren and greatgrandchildren and ..... Here is the code so far - I have commented it heavily: <?php $homepage = $pages->get("/"); $children = $homepage->children; $children->prepend($homepage); echo "<ul class='nav'>"; foreach($children as $child) { // Some variables $aclass = count($child->children) ? "dropdown-toggle' data-toggle='dropdown" : ''; $dropclass = count($child->children) ? "dropdown" : ''; $dropcaret = count($child->children) ? "<b class='caret'></b>" : ''; $class = $child === $page->rootParent ? " active" : ''; // first level <li> // Start by printing off those that actually have children and are not the homepage. if($child->numChildren > 0 && $child<>$homepage){ echo "<li class='$class $dropclass'><a class='$aclass' href='{$child->url}'>{$child->title}$dropcaret</a>"; // Drop down of second level if(count($child->children)){ echo "<ul class='dropdown-menu'>"; foreach($child->children as $subchild){ $subdropclass = count($subchild->children) ? "dropdown-submenu" : ''; echo "<li class='$subdropclass'><a href='{$subchild->url}'>" . $subchild->title . "</a>"; // Second level list // HELP WITH THIS SECTION // This next bit is the sub menu and needs to go on for infinity! // I dont know how to do that. if(count($subchild->children)){ echo "<ul class='dropdown-menu'>"; foreach($subchild->children as $babychild){ echo "<li ><a href='{$babychild->url}'>" . $babychild->title . "</a>"; // 3rd level list echo "</li>"; } echo "</ul>"; } // End of the sub menu bit that I need help with. echo "</li>"; // end second level list } echo "</ul>"; } // end second level echo "</li>"; // End first level // And finally, do the top level menu items that dont have children and chuck in the homepage. }else{ $class = $child === $page->rootParent ? " class='active'" : ''; echo "<li$class><a href='{$child->url}'>{$child->title}</a></li>"; } // end the loop } echo "</ul>"; So: 1. Can some nice person show me how to keep the bit I have marked with "Help with this section" going ad-infinitum? 2. Is there a better way of doing this? I will make the person a cup of really good espresso next time they pop round! Honest! Joss
  5. HI and Welcome Manaus! Yep, I would say ProcessWire is perfect for this. You need to break this down into two sections: How you detail each apartment How you list/categorise them To start with, as Ryan loves pointing out (quite correctly) the page system of parents and children is really a category system - ready to go. Having said that, you may not want everything as part of a menu - especially if there is huge amounts of this! But that is no problem. Using the API it is very easy to group pages under "hidden" pages (they are published but not viewable) and then write increadibly easy code in your template files to retrieve them I do news systems like this. Since, apart from the page hierarchy, there is no built in Category system, you can simply create your own, So, you could create sets of pages (which will be your categories) that are buildings. You could also create another set that are apartment size You could create another that is price range. If you check out the ProcessWIre skyscraper demo, that does pretty much what you are after. When it comes to information - you can create whatever fields you want for a template. So you can make the data entry side very ridged. You can create selects using groups of pages (trust me, it is the best way) if you want to restrict how data is entered, you can use the Thumbnails image plugin to create exact size images and then spin them off into galleries - really anything you want. You may want to look at: Skyscraper demo: http://processwire.com/demo/ A reasonably comprehensive getting started tutorial: http://wiki.processwire.com/index.php/Basic_Website_Tutorial An article about using pages as select fields: http://wiki.processwire.com/index.php/Page_Field And obviously, keep asking question here. Good luck
  6. I have nearly sorted it out fully - I just want to sort out the menu script to make it better. (Which means I will probably be crying for help from somewhere!)
  7. Joss

    The power of Blocks

    Well, like anything ProcessWire shaped, the way you decide to do this will more reflect on how you want to use it rather than anything else. In this case it is for a bootstrap based site and I wanted to create a very set way for every block. So, I create a block template with the following fields: Title Show title (checkbox) Link title (page select) Use Link (checkbox) Text (a tinymce field with only bold, italic and link) Image field (with some dimension restrictions) Image below (checkbox - by default the image is above the text, tick to move it below the text) Link image (checkbox - uses the above link for the image as well) Block theme (page select - from a list of themes that are in my css - just background-color and color plus link color) Use theme (checkbox - so you can switch the theme off without forgetting which one you used) The block pages are created under a hidden page. The themes are pages also created under a hidden page with just two fields - title, to describe the theme, and a text box to put the actual style name in. Each page template that I want to use blocks in has a repeater field with two fields in it: Block_select (page field so you can choose a single block from where ever in your page tree you store them) Span (text box/integer with a max value of 12 for defining the bootstrap span width for horizontal rows.) If I didn't need the span, I could just use a page field set to multiple and the amsSelect type so that I can rearrange the order. So, now I can create a library of blocks with images (or not) text (or not) and call them into specific parts of my site related to specific pages. However I want to do them. For instance, in my footer.inc file I have a row for blocks that are shown throughout the site. I created a special hidden page just for selecting which blocks go into the footer. I have created a separate include file with all the layout for the blocks, and then I include this in various other template files, and just pass a variable ($theseblocks) from the parent template file which is the actual repeater field being used for that particular page. Just for interest, here is the blocks file with all the code to either show or not show various bits and so on: <?php if(count($theseblocks) > 0){ ?> <div id="myboxes" class="row-fluid"> <?php foreach($theseblocks as $thisblock) { ?> <div class="block-padding <?php if($thisblock->block_span) { echo "span".$thisblock->block_span; } ?> blockcontainer <?php if($thisblock->block_select->block_show_theme) {echo $thisblock->block_select->block_theme_select->block_class;} ?>" > <?php if($thisblock->block_select->block_show_icon) { ?> <div class="row-fluid"> <div class="span3 blockicon"><img src="<?php echo $thisblock->block_select->block_select_icon->icons->url; ?>" /></div> <!-- Title with Icon --> <div class="span9 blockicontitle"> <?php if($thisblock->block_select->block_show_title){ if($thisblock->block_select->blocks_enable_link) { echo "<a href='" . $thisblock->block_select->block_link_title->url . "'>"; } echo $thisblock->block_select->title; if($thisblock->block_select->blocks_enable_link) { echo "</a>"; } } ?> </div> </div> <?php } else { ?> <?php if($thisblock->block_select->block_show_title){ ?> <div class="row-fluid"> <!-- Title, no icon --> <div class="span12 blocktitle"> <?php if($thisblock->block_select->block_show_title){ if($thisblock->block_select->blocks_enable_link) { echo "<a href='" . $thisblock->block_select->block_link_title->url . "'>"; } echo $thisblock->block_select->title; if($thisblock->block_select->blocks_enable_link) { echo "</a>"; } } ?> </div> </div> <?php } ?> <?php } ?> <!-- Image Below Text --> <?php if($thisblock->block_select->block_image_below) { ?> <?php if($thisblock->block_select->block_tinymce_body) { ?> <div class="blockbody"> <?php echo $thisblock->block_select->block_tinymce_body; ?> </div> <?php } ?> <?php if($thisblock->block_select->block_image) { ?> <div class="blockimage"> <?php if($thisblock->block_select->block_link_image) { echo "<a href='" . $thisblock->block_select->block_link_title->url . "'>"; } ?> <img src="<?php echo $thisblock->block_select->block_image->url; ?>" /> <?php if($thisblock->block_select->block_link_image) { echo "</a>"; } ?> </div> <?php } ?> <?php } else { ?> <!-- Image Above Text --> <?php if($thisblock->block_select->block_image) { ?> <div class="blockimage"> <?php if($thisblock->block_select->block_link_image) { echo "<a href='" . $thisblock->block_select->block_link_title->url . "'>"; } ?> <img src="<?php echo $thisblock->block_select->block_image->url; ?>" /> <?php if($thisblock->block_select->block_link_image) { echo "</a>"; } ?> </div> <?php } ?> <?php if($thisblock->block_select->block_tinymce_body) { ?> <div class="blockbody"> <?php echo $thisblock->block_select->block_tinymce_body; ?> </div> <?php } ?> <?Php } ?> </div> <?php } ?> </div> <?php } ?> Yes, I know it needs tidying up - I haven't had time yet!
  8. That is not an issue - most consumer laws say you are agreeing to the published price - or display price in a website - plus any additional charges that are clearly displayed. What you are suggesting is like going into a shop, picking up an item marked for ten pounds/dollars/franks/yen/ and then leaning over the counter and changing the till value to a pound.
  9. Typical - just when I thought I had leaned something! Can you explain how that works if, for instance, I need to add a class to the first iteration?
  10. Joss

    Freeing the Captcha

    I would think that the majority of sites where they have some sort of sign up that needs spam protection, are probably also going to rely on cookies for other things. So, one way or another, the user is going to have trouble.
  11. Looks very nice - I like the way the form looks.
  12. Joss

    Pub Demo Site

    HI Lucas, Not sure, I might do something over some of the elements. The technical side is pretty simple, but actually, that might be the most useful side to explain.
  13. Oh, the Fins I worked with were great, but they came with a health warning. They could REALLY drink!
  14. This is the third of my demos using ProcessWire, attempting to both show the flexibility of the system to local clients and to demonstrate a range of basic site approaches http://pwdemo3.stonywebsites.co.uk/ This one takes the idea of using blocks to an extreme. It allows you to create a large library of blocks with some standard customisations: You can Choose to display a title or not Choose to link the title to another page Additionally, link the image to another page Choose to display an image or not Display the image above or below the text Add a video to the text box Choose an icon from a list (and turn it off and on) Select a colour theme for the block from a pre-designed set Each page has tools to select and arrange blocks from the library - only the footer blocks are controlled globally. I have used a fairly artistic approach for this particular version, but to be honest it could be used for anything Note to self: When dealing with lots of lorem ipsum, don't hit the spell-check button.
  15. Really like this ... and yet again reminds me that I MUST get my general portfolio sorted out! I have only managed the banner.
  16. Joss

    Freeing the Captcha

    I like the challenge/answer one a friend of mine had for the sign up for his quite personal forum. "What is the name of my dog."
  17. Joss

    Freeing the Captcha

    I think there are two problems with reCaptcha particularly: 1. It is difficult to use - I often refresh three or four times to get something I am confident I can read 2. It is very widely used, and therefore users are familiar with it - good for reCaptcha, not so good if you want to move away from it. The problems of any new system is that if people do not recognise it, at least in its form, then it is as much as a barrier as reCaptcha is. To a certain extent this means that is probably better to go with solutions from larger companies that are being pushed heavily so that at least the solution you are using is probably going to grow to be familiar to users. On the downside, as soon as any one solution (or even type of soultion) gets pushed widely, then it becomes a target... A bit of a minefield.
  18. Joss

    Freeing the Captcha

    With Ticket Master announcing that they have dropped reCaptcha in favour of an advertising solution (http://www.bbc.co.uk/news/technology-21260007) the question is, what do you do? Do you just have captcha on signup forms or on everything? Do your clients prefer to advertise their email address and cope with the spam? Have you a great alternative that does not annoy my mother... The days of trust have gone on the internet, but does the current trend of putting up brick walls everywhere risk isolating businesses? What is the best policy? And where a technical solution is required, which is the best one?
  19. Joss

    Cart Keeper

    Yeah, new to me too - though they seem to have been around for some time. The potential is going to dump his copy on a cd so I can install it - Then I will know more. I had a very brief search and I haven't found any themes or templates from third parties.
  20. Joss

    Cart Keeper

    I have just had a potential client call who wants a refresh of their existing shop (not a major change) They are using a software called Cart Keeper Anyone heard of it and know anything about it? And if so, what is it like to theme? It is proprietary, so I cant just down load it. Joss
  21. Thanks Soma. I think your second code is the best work-around!
  22. The problem is that although it is unviewable, it still ends up on the menu. Oh, and good morning! Edit - I mean, the front end menu
  23. I am getting a bit of strange behaviour (that I admit I have not tested properly - I am short of time at the moment) If I create a new page as a child of "home" and choose a template that HAS a template file, then after pressing save, the page is UN published. Good! However, if I create a page as a child of home and choose a template that does NOT have a template file, then after pressing save, the page is PUBLISHED. Not good! This is on the dev version of PW, by the way. Am I missing something? (I usually am)
  24. Welcome, Alex Hey, you would be amazed how you can contribute - sometimes just asking questions gives some of the more experienced developers an excuse to pour forth their knowledge! Cakes look good! (and dangerous for my waist line) and the site seems properly responsive (which is slowly becoming mandatory, I think). I like it. What are you using for the shopping cart?
  25. Having just used this article to simplify some of my own code, I have written up a full tutorial on the wiki using the Bootstrap Collapse plugin as a case study http://wiki.processwire.com/index.php/First_Child_in_a_loop Joss
×
×
  • Create New...