-
Posts
2,778 -
Joined
-
Last visited
-
Days Won
40
Everything posted by Macrura
-
Recently I've been working on a site where it seemed like it was going to be impossible to keep the page tree and the needs of the site's main menu in harmony; So to solve this I setup a separate page tree under a hidden page called 'Main Menu', with each menu item having three fields: title, menu-link-page, and menu-link-url. All of the menu items are also hidden, so the code below uses the include=all parameter when getting the pages for the tree. To generate the main menu markup, i adapted the great code that was developed by Soma for Joss's bootstrap menu, and modified it to output links to the menu-link-page or menu-link-url; (Entering a value in the menu-link-url field overrides any selection in the menu-link-page.) This solution has enabled me to setup the menu exactly how the site needs it, even if the menu heirarchy is not the same as the page heirarchy, and has solved a lot of problems and made things easier for this scenario. For example, menu items can easily contain external URLs, to subdomain pages, or other related site's pages. (In this case the client has a separate web store for selling parts). Also, all of the parent menu items had to use a javascript:void() as the href, in order for the accordion version to work right on mobile; So this was easy to do by putting that into the menu-item-link field. In the code below, page #1271 contains the menu tree, so it is specified as a parameter to the $root variable. I think this sort of setup, using a custom menu tree, could solve a lot of the questions I've seen recently on the forum; I probably wouldn't use this technique on small sites since it is more work, but for larger ones where you might need a lot of menus, this could be helpful. Also, if you had to setup a Mega Menu, with images and icons, this might make it easier to manage. <?php /** * render custom markup menu for bootstrap nested navigation * * @param PageArray $pa pages of the top level items * @param Page $root root page optional, if you use other root than home page (id:1) * @param string $output for returned string collection * @param integer $level internally used to count levels * @return string menu html string */ function renderChildrenOf($pa, $root = null, $output = '', $level = 0) { if(!$root) $root = wire("pages")->get(1); $output = ''; $level++; foreach($pa as $child) { $class = ''; $has_children = count($child->children('include=all')) ? true : false; if($has_children && $child !== $root) { if($level == 1){ $class .= 'parent'; // first level boostrap dropdown li class //$atoggle .= ' class="dropdown-toggle" data-toggle="dropdown"'; // first level anchor attributes } } // make the current page and only its first level parent have an active class if($child->menu_item_page === wire("page")){ $class .= ' active'; } else if($level == 1 && $child !== $root){ if($child->menu_item_page === wire("page")->rootParent || wire("page")->parents->has($child)){ $class .= ' active'; } } $class = strlen($class) ? " class='".trim($class)."'" : ''; if($child->menu_item_url) {$childlink = $child->menu_item_url; } else { $childlink = $child->menu_item_page->url; } $output .= "<li$class><a href='$childlink'>$child->title</a>"; // If this child is itself a parent and not the root page, then render its children in their own menu too... if($has_children && $child !== $root) { $output .= renderChildrenOf($child->children('include=all'), $root, $output, $level); } $output .= '</li>'; } $outerclass = ($level == 1) ? "accordmobile" : ''; return "<ul class='$outerclass'>$output</ul>"; } // bundle up the first level pages and prepend the root home page // $root = $pages->get(1); // $pa = $root->children; // $pa = $pa->prepend($root); // Set the ball rolling... // echo renderChildrenOf($pa); // example with pages further down in the tree $root = $pages->get("1271"); $pa = $root->children('include=all'); // $pa = $pa->prepend($root); // add the root as the second parameter echo renderChildrenOf($pa,$root);
-
Get first image from a repeater field on another page and resize it?
Macrura replied to Lance O.'s topic in General Support
since i've done this kind of thing a lot, the first thing i notice about your setup is that you are using an image field within a repeater, but the image field already supports multiple images, so if i was doing this, i would not use a repeater, but just a plain image field, that allows multiple images. if you are only going to have 1 featured project, then this should work, assuming you don't put the image_field inside a repeater: $featured = $page->featured_project; $img = $featured->images->first(); $thumb = $img->size( 100, 100 ); -
Get first image from a repeater field on another page and resize it?
Macrura replied to Lance O.'s topic in General Support
sounds like you have to maybe first setup a loop for the featured projects?, and then setup a variable to hold each of the featured projects..something like this? $featured = $page->featured_project; foreach ($featured as $feature) { $img = $feature->images->first(); echo $img } -
I've been seriously researching the options for digital products (e-goods) since we have several record label clients running stores that sell music downloads, and we're attempting to migrate away from Joomla, where we have been using a component for this. So far my experience with Ecwid has been great - the pricing is very reasonable, they have a free plan, and everything seems to work well; For e-goods, you get 100 products, unlimited storage and bandwidth for $15/month. The only issue is the 100MB max on the filesize, but there are ways around that, such as splitting large files into multi-part archives, however this can be less than convenient for the end user than just getting the complete file. Ecwid integration with processwire is nothing; the only thing that could get tricky involves the SEO with ajax, and they have instructions for how to get this setup right; Most people would have a separate page for each product in PW anyway, so that wouldn't be an issue. the other e-goods options I have looked at include: http://www.fetchapp.com https://gumroad.com/ http://quixly.com/ http://pulleyapp.com/ Fetchapp's pricing (http://www.fetchapp.com/pages/plans) can't really compete with Ecwid, unless you use the $10 "use your own server" plan, and then host the files on s3. I think one advantage of fetchapp is that it can host larger files without breaking them up; The only other thing is that Fetchapp is digital goods only, while Ecwid can do both digital and physical.. Gumroad looks cool- there is no monthly fee, and you don't need to have a payment gateway, like PayPal... this article was kind of helpful... http://www.smashingmagazine.com/2012/03/29/selling-digital-goods-online-e-commerce-services-compared/ -marc
-
Hi Luis, this is my temporary solution - it works for now, but i'm thinking i should do this with a session variable so that if the user refreshes the page or navigates away, and comes back, they don't have to re-enter the password; Also i need to provide an error message... thanks again for your help; I'll see if i can improve my knowledge/use of the api with respect to $input and $session... <?php if($page->album_password) { $pass = $page->album_password; if($input->post->pass != $pass) { ?> <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Login to view <?php echo $page->album_title ?></title> </head> <body> <form method="post" action="./" accept-charset="UTF-8"> <input type="password" id="pass" name="pass" placeholder="" /> <button type="submit" name="submit" class="btn btn-success btn-block">Login</button> </form> </body> </html> <? } else { include("./inc/album.inc"); } } else { include("./inc/album.inc"); } ?>
-
Hi Luis, I've almost got this working, the main issue now is that the code seems to loop, and also i was getting an error because of the unmatched brace on the } "// end !logged in" line... maybe that's why this is not working? so after you click the login button, you keep getting back to the login page, i guess because since it is all on the same template? I tried an alternate idea of having only the login code on the template and then including the markup code for the page, contingent on being logged in, which works; but i'm not sure this is necessary - and with this method i can't figure out how to throw the wrong password error... thanks again for your advice and the code! -marc
-
Hi Matthew - thanks - yes i have a policy where i will only do sites where someone associated is a Sopranos double; And you're right about those little grey boxes, the font is a bit small...I'll have to mention that to the client.. Oh - and to follow up about Joomla expats...easy way to identify us, we all look quite relieved.
-
Thanks Luis, I really appreciate your post - this looks like a very simple/elegant way to do this - i'll report back as soon as i have a chance to integrate this. -marc
-
It would be 1 password to access the album, everyone with the password would be able to access it; this will be on a non search indexed subdomain of their main site, the links only given to the various press/reviewers. after the promo period, they would unpublish the page, and we would use the redirects module to send incoming requests to a contact page;
-
I have a client who is a record label and they need to have some pages for promoting albums, where there can be a password they give to a reviewer, so the reviewer can go to the URL, type in the password, and be able to view the content (which will be streaming audio and downloads of the album in question). i have found some simple ways online to do this with PHp, but i'm wondering if there is a better/simple way to interact with PW session to achieve this. The client doesn't want to have to add roles/users or deal with permissions...they just want to have an input field where they can put in the password for that album... TIA, Marc
-
thanks all for taking a look at this. As i said, this was the first PW site done for a client, and despite the learning curve, it all went relatively fast, and what was especially important was how i was easily able to respond immediately to any request the client had; is seemed that the answers to virtually all of my questions were already in the forum, and when i couldn't find a way to do something, the forum came up with solutions. The site has been live for over 3 months, and none of the content has gotten messed up..(thanks to PW fields, and limited use of WYSIWYG..!) Which is very refreshing, after coming from the world of mostly Joomla, where all of my clients seem to go especially wild with fonts, bold, italic, spacing, font size, (and makes it look AWFUL!) and then i have to periodically go in and do spring cleaning for spans... Also - I haven't had to provide any training, tutorials, or support for this site since the site went live, which also illustrates how easy, and user-proof PW is. As far as why no women composers...ha... that's an interesting question, and i'll have to ask Howard about that next time i speak with him.. but it is a statistical reality in contemporary music that men outnumber women... and I once heard a conjecture from my freshman music history professor, who said that males are more driven to compose because they can't biologically propagate the species...
-
Hey thanks Joss- i'm also a musician (performer/composer) masquerading as a web developer.... since you're a composer, you might like this, which is running on PW: -marc
-
Thanks all for checking it out and the likes. this site is using formbuilder, as well as solutions from these forum threads: though currently the homepage pop up is disabled... the forum has been an essential resource! -marc
-
Hi, Here is another processwire powered site, completed recently. http://www.kapelis.com/ the way this is setup would not have been possible without processwire, which has made it easy and accessible for the client to update all aspects of the site without having to code or use a wysiwyg... -marc
-
@soma - advice taken ! thanks -marc
-
thanks netcarver & diogo - it's working and so simple to implement with PW. this is what i ended up with: <?php if(!$session->noPop){ include("./popup.inc"); $session->noPop = 1; } ?> -marc
-
Hi diogo - thanks for the code - i tried it but couldn't get it to work, though i think i understand what this is doing; what if a visitor lands on an inside page, but then clicks to the homepage; i think i need to setup a session variable when the visitor lands on the homepage, which can be compared when they come back a 2nd time...? -marc
-
I have a client who wants to have a modal pop up box (i'm using the Zurb 'Reveal' jquery plugin for it) on their homepage, but they only want it to appear once per visit, so if the user clicks back to the homepage, they don't get the pop up again. Just wondering if anyone has any idea how to do this with php/processwire, or should i be using jquery cookies? Thanks, Marc
-
Hey diogo - thank you for checking out the site, and for pointing me to the responsive images solution; i'll see if i can donate some more time to this and integrate that;
-
@teppo - thanks for checking it out; I'm going to do some optimization; i just enabled gzip in the htaccess; (i was avoiding doing too much work since it's sort of a donation project) but i think i'll probably also setup minify on the scripts and css; for the images, they are huge; i'll have to see if i can reduce the size, maybe downgrade the jpeg quality and save some bandwidth... @WillyC - yes, i guess you have to go to the class to see more...and this it hot yoga, so the room is really hot/humid...you sweat a gallon.
-
@Nico - this is using Ecwid, which is a great ecommerce plugin; http://www.ecwid.com you setup all the products over on the ecwid account (this site is using the free plan), then you can get the add to cart code and paste it in; but since it is easy to get custom output in PW, i just have the users enter the product id # into the PW page and then the necessary code to display each button is automatically output in a foreach... <form><script type="text/javascript">xAddToBag('productid=<?php echo $product_id ?>');</script></form> @arjen- thanks for checking it out - it's nice to use the PW logo instead of just a text link, since IMHO it is the hippest CMS logo out there;
-
New site made with PW: http://yogacentergreenwich.com/ [edit - should have provided some details...] - formbuilder for contact form - image gallery pagination code from here - pw logo from here - ecwid for shopping cart - campaign monitor for the newsletter -marc
-
Thanks Ryan for your input on this and for the offer of the code. I'm still considering alternative options for this, and it's sort of low-budget and then need it soon, so i may end up having to go with a prebuilt system; I'll get in touch if/when that option looks necessary.... -marc
-
Thanks a lot Tom! I did look at that post, so thanks for reminding me about that; I guess i'm just going to go for it with PW; the client want's something uber-simple and minimal; the users of this system will be mostly 65+ and i'm wary of doing it with one of the big three, since it's always so hard to hit the target exactly with those pre-built components/plugins... I'll see how far i can get and post back here. -marc
-
I'm trying to determine if i can build a site for a client using PW; this client has requested a site for a homeowner's association; - members only site - front-end user login (about 70 users) - when users login they will be able to -view a list of announcements, and a list of events - submit an event (planning to use the formbuilder, post to 'events' page) - submit an announcement (formbuilder -> page) after reading many posts on the forum, it seems that this can be done without a tremendous amount of code (also thanks to the formbuilder); the area i'm not sure about is having users be able to edit a submission, or their own user data; so if they submit an event or announcement, how to have them be able to edit it, on the front-end once they are logged in, and also how to enable them to have access to their user data (i.e. to change username, password or other fields); TIA, marc