Jump to content

thetuningspoon

Members
  • Posts

    691
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by thetuningspoon

  1. Thanks Ryan, I'll give both suggestions a shot. Forgive me for asking if this is already documented on the site somewhere (I couldn't find it), but what is the recommended upgrade procedure? Update: Setting the superadministrator through a template didn't solve the issue. EDIT: Found the article on how to upgrade.
  2. Hey guys, I was working in the access tab (ProcessWire 2.2.0) and suddenly I can no longer view or edit roles. Instead of taking me to the edit role page when I click on a role, it brings me back to the pages list and says "You are logged in." I logged out and back in again and tried an alternate browser but I'm still having the issue. The original issue that I was having was that my site editors were unable to publish new pages, so I was looking for a fix for that when I came across this issue. I am logged in as a superuser and am using the default admin interface. Any ideas? Thanks.
  3. I had the same problem on my local server while using MAMP on a Mac. I was able to solve it by adding the following to my VirtualHost declaration in httpd-vhosts.conf: <VirtualHost *:80> DocumentRoot "/Users/username/Test Site" ServerName testsite.loc <Directory "/Users/username/Test Site"> AllowOverride All </Directory> </VirtualHost>
  4. I've put together some php (with the help of you guys on the forum) to create a hierarchical list menu. It uses a function which it calls recursively to create the drop-downs/submenus. It works great, but now my client has thrown a wrench in the works: they want the first link on all (or most) of the submenus to be an "overview" link which actually just directs you to the parent link, in case people don't realize they can click on the top level link itself. I'm having trouble figuring out how to do this with my current php, but I'm also wondering if there might be a better way to do it altogether: by creating the overview as its own "page" in the site structure. If I do this, what's the best way to get that page to simply redirect you to a different page? PHP header redirect in the template file? Thanks for your help. The code I'm using for the menu is below. <?php //Choose the parent page you want the menu to be based on $parentPage = $pages->get("/"); //Set a limit for the number of top level menu links $children = $parentPage->children("limit=6"); //Include the parent page as the first item in the menu $children->prepend($pages->get("/")); //Call the function to build the menu tree listChildrenTree($children); function listChildrenTree($children) { ?> <ul> <?php //Loop through each of the child pages foreach($children as $page) { //If this is the current page, create a CSS class for it $class = $page->id == wire('page')->rootParent->id ? "class='on'" : ''; //If this is the homepage, use the following image $homeImg = ''; if($page->id == wire('pages')->get("/")->id) { $homeImg = '<img src="' . wire('config')->urls->templates . 'styles/images/home.png" width="24" height="28" alt="" />'; } //Markup time! ?> <li> <a href="<?php echo $page->url ?>" <?php echo $class ?>> <?php echo $homeImg ?> <?php echo $page->title ?> </a> <?php //If the current page has children and it is not the homepage, call the function recursively to create a submenu if($page->numChildren && $page->id != wire('pages')->get("/")->id) { listChildrenTree($page->children); } ?> </li> <?php } ?> </ul> <?php } ?>
  5. Sorry Ryan, I didn't see the "echo" in your post. I tried it out and there was no output. Thanks for the other suggestions, guys. I'll get back to this in a bit.
  6. form_name is a field on the current page which holds the name of the template I want to load. That's what it's supposed to do, at least. If I hardcode the template name in, it works fine. But this bit of code doesn't seem to work.
  7. I will check again, but I tried hard-coding the template name and it worked. echoing $page->form_name output the exact same string, so I'm utterly lost as to why it's not working.
  8. I'm looking into developing a site with a "members-only" section in the front-end. I've been playing around with creating new users in the back end and then using the API to show certain content only to members logged in with certain roles, etc. It's really fantastic and I love how flexible it is. Now I'm at the point where I'd like to provide a form which displays to visitors who are not logged in and allows them to do so (obviously I don't want to have to direct users to the default admin login page to log in). However, I have no idea how to do this... I tried looking at the code for the admin login page to see if I could borrow from that, but I can't even figure out where the code for the form is! Any help would be much appreciated, as always
  9. Thanks for your help, diogo, and for explaining the Page FieldType option. But going back to using a simple textbox, I still have the problem of getting the $page->form_name call to work in this context. If I use it elsewhere on the page to simply echo the content of the field, it works fine. But when I put it in the context of the code block above (2nd line, sorry), I receive an error.
  10. I'm stumped. I'm playing around with Ryan's formbuilder. For the template that loads the form, I would like to make the form template to be loaded something which can be set on the backend through a text field (or, ideally, a drop-down selection box with the templates pre-populated, but I can't even begin to think of how to do that). So here is what I'm doing. The 3rd 2nd line down is the one that I'm having trouble with. form_name is the textfield which holds the name of the template I want to load. I get the error: "Fatal error: Exception: You must specify a Template" $form = $modules->get('FormTemplateProcessor'); $form->template = $templates->get($page->form_name); // required $form->requiredFields = array('fullname', 'email'); $form->email = 'mspooner@solutioninnovators.com'; // optional, sends form as email $form->parent = $page; // optional, saves form as page echo $form->render(); // draw form or process submitted form
  11. I can't seem to get permissions to work correctly. I added a new role for users I want to be able to edit pages but not do administrative things (like editing users or fields/templates), assigned the edit permission to the new role, and yet when I log in as the user I don't have any edit capability. I'm using Processwire 2.2.0. What could I be missing?
  12. Whoops, nevermind. It's including both classes now. This must have been an error on my part somehow. Thanks!
  13. Hey guys, I'm trying to grab the name of the current template in order to apply it as a body class which I can use to tweak my CSS based on the template I have loaded. I'm using $page->template->name to achieve this. It works, except when I have the adminbar installed. If the adminbar is running, the template name is output as "adminbar-loaded" instead. Any way around this?
  14. I ended up using: if( $newsChildPage->id === $newsChildrenArray->first()->id ) to keep thing consistant since I am also using last(), which can't be found (I don't think?) with the counter method. Thanks for demonstrating how to use the counter with foreach, Ryan. Didn't know about that one! If anyone is interested in using something like this on their own project, here is my updated code, which includes the logic for removing articles that we don't want in our list (making use of a custom checkbox on news article pages). Instead of using the heredoc syntax, I tried to go with more separation of the markup and php. Not sure if I succeeded or not <ul class="news-previews"> <?php //Create an array from the children of the news page $newsPage = $pages->get("/news/"); $newsChildrenArray = $newsPage->children; //Remove articles we don't want published on the homepage from the array foreach($newsChildrenArray as $newsChildPage) { if($newsChildPage->publishOnHomepage == false) { $newsChildrenArray = $newsChildrenArray->remove($newsChildPage); } } //Loop through the modified array and output the articles foreach($newsChildrenArray as $newsChildPage) { //Grab the first image in the article, if one exists $newsImg = ''; if( count($newsChildPage->images) ) { //If this is the first article, make a larger image if($newsChildPage->id === $newsChildrenArray->first()->id) { $newsImg = $newsChildPage->images->first()->size(150,150); } else { $newsImg = $newsChildPage->images->first()->size(57,51); } } //Set a class if this is the first or last item $class = ''; if( $newsChildPage->id === $newsChildrenArray->first()->id ) $class = 'class="first"'; if( $newsChildPage->id === $newsChildrenArray->last()->id ) $class = 'class="last"'; //Markup time ?> <a href="<?php echo $newsChildPage->url ?>"> <li <?php echo $class ?>> <?php if($newsImg)echo '<img src="'.$newsImg->url.'" alt="'.$newsImg->description.'"/>'; ?> <p> <h4 class="preview-title"> <?php echo $newsChildPage->title ?> • <span class="preview-date"><?php echo $newsChildPage->date ?></span> </h4> <?php echo $newsChildPage->summary ?> <a href="<?php echo $newsChildPage->url ?>" class="read-more">Read More...</a> </p> </li> </a> <?php } ?> </ul>
  15. Thanks a lot Soma. Using a counter like Arjen suggested is the workaround I am currently using, but I think I will use your code because I like it better Well, I want to check whether it exists and do nothing if it doesn't. I suppose I should use isset()?
  16. I'm creating a news section on my homepage which outputs a list of article previews with an image, link, and summary for each. I have this working perfectly. However, I want to have the first article in the list have a larger image and some different classes for styling. Here is my code, which uses first() on the $newsChildrenArray array to test against the current item ($newsChildPage) in the foreach loop and create a larger image if they match up: foreach($newsChildrenArray as $newsChildPage) { //Test for an image on the current page if($newsChildPage->images->eq(0) != null) { //If this is the first article, make a larger image if( $newsChildPage == $newsChildrenArray->first() ) { $newsImg = $newsChildPage->images->first()->size(157,151); } else { $newsImg = $newsChildPage->images->first()->size(77,71); } } echo ' <a href="' . $newsChildPage->url . '"> <li '; if($newsChildPage == $newsChildrenArray->last())echo 'class="last"'; echo '>'; if($newsImg) { echo '<img src="' . $newsImg->url . '" alt="' . $newsImg->description . '" />'; } echo ' <p> <span class="preview-title">' . $newsChildPage->title . '</span> • <span class="preview-date">' . $newsChildPage->date . '</span> <br />' . $newsChildPage->summary . ' <a href="' . $newsChildPage->url . '" class="read-more">Read More...</a> </p> </li> </a> '; } Unfortunately, ProcessWire chokes on the test. It echos the first element in the array correctly and then spits out "Fatal error: Nesting level too deep - recursive dependency?" Strangely, it has no problem with the similar test I perform later on using last() to output a class on the last array element. I created a simple workaround by adding a counter to the foreach loop and testing for the first element in the loop, but I'm curious--for future reference and a better understanding of the API--why this would be failing. Is there a better way of doing this that would still utilize the PW API?
  17. Thanks, DaveP. I used if($page->images->eq(0) != null) { do something; } Was a little confused by your example until I read the explanation of eq() in the cheatsheet.
  18. Hey guys, I think I'm really starting to get the hang of working with the ProcessWire api, following along with the cheatsheet. However, I'm drawing a blank on this. How do I test to see if the images field of a specific page contains any images? Same goes for the other field types. I know you can test for the existence of the field type on the page, but can you test for whether it has any data in it? Thanks!
  19. Thanks guys! It could probably use a third breakpoint in there, but budget didn't really allow for it. Building it responsively was already going beyond the scope of the original project.
  20. My company has just launched our first site for a client built on ProcessWire. It was an absolute pleasure working with ProcessWire and we look forward to building many more sites on it. The drag-and-drop image uploading, combined with the built-in PW resizing functions is brilliant for clients who need to easily add photos. As a designer, PW does an awesome job of staying out of the way when it should. I love that I can pretty much build a site exactly as I normally would and then integrate PW on top of that. Because PW doesn't output any markup, building this site responsively was a breeze. Woot! So, without further ado... http://www.ctporcelainpainting.com
  21. I know, right? I've had to go back and work on Joomla sites and it's just such a chore to do anything, even simple updates. Processwire is clean and logical, and just a joy to work with.
  22. Whoops, that should have been an easy one to spot. Thanks guys!
×
×
  • Create New...