Jump to content

onjegolders

Members
  • Posts

    1,147
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by onjegolders

  1. This is one of those moments when I question what I'm doing with my life! Spend 7 hours today trying to figure out this one problem (sometimes I really think I would pay for commercial support ) Seems I should have been setting a $category variable and checking for name=$name (so essentially was missing a step) I must have spent about a million hours trying to figure that out... One thing I can't seem to figure out though is how to only show links to categories that have been used once or more. Currently it is showing all categories, even if they're empty. The tiny logical part of my brain is saying that I should be referencing events and not categories Something like: $cats = $pages->find("template=event")->categories; But can't seem to figure it out
  2. I may not be the best person to answer as am a relative newcomer and am sure someone more experienced will be along to help soon but a few things to check in the meantime. What is currently in your root folder? Do you see an htaccess file?
  3. Thanks, have spent this morning trying to get this to work but I'm just not managing it unfortunately. I've gone down the include route so that now, my event index page looks like this: <?php include("./header.inc"); ?> <?php if ($input->urlSegment1 != "") { include ("./categories.inc"); } else { ?> <div id="events_index_wrap" class="bg_gradient"> <div id="events_index_main"> <h3 class="page_header">Upcoming Events</h3> <?php $entries = $pages->find("template=event, sort=date"); $count = 0; foreach ($entries as $event) { $count++; $class = "event_box"; if (0 == $count % 2) { $class .= " event_box_second"; } ?> <div class="<?php echo $class; ?>"> <div class="event_box_text"> <h2><a href="<?php echo $event->url; ?>"><?php echo $event->title; ?></a></h2> <h5><?php echo $event->date; ?></h5> </div><!-- /.event_box_text --> <div class="clear"></div> <?php if ($event->images) { $img = $event->images->first()->size(220,165); ?> <a href="<?php echo $event->url; ?>"><img src="<?php echo $img->url; ?>" width="<?php echo $img->width; ?>" height="<?php echo $img->height; ?>" alt="<?php echo $entry->title; ?>" class="med_frame" /></a> <?php } ?> </div><!-- /.event_box --> <?php } ?> </div><!-- /#events_index_main --> <div id="events_index_side"> <div class="events_index_side_box"> <?php if (count($pages->find("template=category"))) { $category = $pages->find("template=category"); ?> <ul> <?php foreach ($category as $cat) { ?> <li><a href="<?php echo $page->url . $cat->name; ?>"><?php echo $cat->name; ?></a></li> <?php } ?> <?php } ?> </div><!-- /.events_index_side_box --> </div><!-- /#events_index_side --> <div class="clear"></div> </div><!-- /#events_index_wrap --> <?php } ?> <?php include("./footer.inc"); ?> So on the category list, I tack on the category name to the url and if there's a URL segment it includes the categories include, which looks like: <div id="events_index_wrap" class="bg_gradient"> <div id="events_index_main"> <h3 class="page_header">Upcoming Events - <?php echo $input->urlSegment1; ?></h3> <?php $name = $sanitizer->pageName($input->urlSegment1); echo "<h1>$name</h1>"; $entries = $pages->find("template=event, categories=$name, sort=date"); $count = 0; foreach ($entries as $event) { $count++; $class = "event_box"; if (0 == $count % 2) { $class .= " event_box_second"; } ?> <div class="<?php echo $class; ?>"> <div class="event_box_text"> <h2><a href="<?php echo $event->url; ?>"><?php echo $event->title; ?></a></h2> <h5><?php echo $event->date; ?></h5> </div><!-- /.event_box_text --> <div class="clear"></div> <?php if ($event->images) { $img = $event->images->first()->size(220,165); ?> <a href="<?php echo $event->url; ?>"><img src="<?php echo $img->url; ?>" width="<?php echo $img->width; ?>" height="<?php echo $img->height; ?>" alt="<?php echo $entry->title; ?>" class="med_frame" /></a> <?php } ?> <?php $categories = $event->categories; foreach ($categories as $cg) { ?> <h6><?php echo $cg->name; ?></h6> <?php } ?> </div><!-- /.event_box --> <?php } ?> </div><!-- /#events_index_main --> <div id="events_index_side"> <div class="events_index_side_box"> <?php if (count($pages->find("template=category"))) { $category = $pages->find("template=category"); ?> <ul> <?php foreach ($category as $cat) { ?> <li><a href="<?php echo $page->url . $cat->name; ?>"><?php echo $cat->name; ?></a></li> <?php } ?> <?php } ?> </div><!-- /.events_index_side_box --> </div><!-- /#events_index_side --> <div class="clear"></div> </div><!-- /#events_index_wrap --> My issue is that I'm pretty sure that the category name is matching the urlSegment but when I choose a category the list comes up empty. I've thought of possible reasons (lower/upper case categories?), I've also tried to pass a variable to the current category but not to sure how to get that working before looping through the entries... If anyone has any idea, that would be much appreciated, thanks.
  4. Yep that's exactly right Diogo, before I was getting pictures always from the same "album" (page) and that page changed randomly. Your code Soma looks like it could work so thanks guys!
  5. Thanks Ryan, is it possible to get all the images that use the template and then randomly choose 6 photos?
  6. Thanks Ryan, that makes it clearer, though I'm still unsure what I should be doing on my events "index" page. On the left I display all the events and in the sidebar I ideally wanted to list the categories and then on click, filter the entries (I suppose at events/category_name). Sorry for being slow, just not quite sure how to link this up. On your video example, you only seemed to have a small bit of code in one template which did all the magic!
  7. I've used similar code and got it displaying 6 random images, however I want it to show 6 random images from across all the pages that share the gallery_entry template. At present it's only showing from the same album (page): <?php $images = $pages->get("template=gallery_entry, sort=random")->images->getRandom(6); foreach ($images as $image) { $img = $image->size(80,60); ?> <a href="<?php echo $config->urls->root; ?>albums"><img src="<?php echo $img->url; ?>" width="<?php echo $img->width; ?>" height="<?php echo $img->height; ?>" alt="Latest Photos" /></a> <?php } ?> Any idea on how to get random images from more than one page? Thanks
  8. I've been reading up on a few posts on categories but I'm struggling to get them working. I saw a video from PW1 and the example seems nice and simple:Output the categories, click one and the list of entries gets filtered. I tried to replicate that but no joy. I can't seem to understand how Ryan can output $page->categories from his page when really the categories are surely part of children()? Is it really possible to filter categories of events or news this simply? I've seen other examples in the forums which look much more complex (urlSegments and the like). I currently have my category page set up as a child of home, and categories as its children. Before seeing that video, I had managed to output the categories like this: <div id="events_index_side"> <?php if ($pages->find("template=category")) { ?> <div class="events_index_side_box"> <h5 class="page_header">By category</h5> <ul> <?php $categories = $pages->find("template=category"); foreach ($categories as $category) { ?> <li><a href="<?php echo $page->url . $category->name; ?>"><?php echo $category->title; ?></a></li> <?php } ?> </ul> </div><!-- /.events_index_side_box --> <?php } ?> but using this method, I'm not quite sure how I can get the page to reload with just those categorised entries? Would appreciate if anyone could give me a shove in the right direction. Thanks.
  9. Just been reading this article and apart from wanting to applaud your enthusiasm and integrity, two points struck me in particular: Think MarcC's ideas of site profiles could appeal to large amounts of people. As a reasonably fresh-to-web designer, I love the control Processwire gives to me and my markup, the thought of having to use Joomla or Wordpress would fill me with dread. I am very aware however that although almost anything is buildable in PW, I couldn't build it. My brother who uses Joomla, often asks me what will happen when I need to set up a forum or a social network or a shopping cart. I would love to be able to build all this myself and as a firm believer in DIY code, I think it would be a cleaner solution but I just wouldn't have the expertise to pull it off - I do believe, however, there are one or two devs in this community who could make some really excellent profiles, which I would gladly pay for (and to which you should take a cut sir!) This sort of brings me to my other point. Let there be commercial addons (profiles) but let them be for very specific non-core functionality. In EE, the addons are generally terrific and I had no problem paying for Firemail (a newsletter system), or CartThrob as an example but it really hurts to have to fork out money for addons that you just know should be part of the core. They all add up. If I can handcraft a great site with PW knowing that if I need a large bit of expert functionality further on down the line, like a shop or a forum, I'd happily fork some money for it, as it would mean I wouldn't have to consider moving to the dark side (mentioning no names )
  10. Am trying to list 3 other events (siblings) at the bottom of an event page. My problem is I can only seem to limit before I remove the $page part meaning I end up with only 2 other events at the bottom of the page. Have tried the following but doesn't seem to work: $page->siblings->remove($page); $events = $page->siblings("limit=3"); I've tried various things but perhaps someone more knowledgeable could point me in the right direction? Thanks
  11. Sorry Ryan, I seem to be getting just one blog entry showing up when I add my code to yours, do you have any idea why that may be? If not, don't worry, I'll just drop that part of the page as it's getting the better of me!
  12. Thanks, I think when I get bogged down in things like this, I may start again and go through step by step, better to do it that way and you always end up wiser at the end!
  13. Thanks Ryan that clears it up for me!
  14. Yes sorry Ryan it is browser autocompletion, I think EE somehow linked the title tag to the URL tag so that it updated even when using a browser autocompletion. Certainly not a critical feature just wasn't sure if you were aware! A screenshot speaks a thousand words....
  15. Thanks Ryan, thanks for your kind words, I do feel good just learning the basics of this system, it's so intuitive and the support is pretty damn good too
  16. Hi guys, sorry to be bugging you, was just wondering if anyone with more PHP experience may be able to see a line or two in my code which is stopping the form from working. It's essentially a working contact form that Ryan helped me with to which I'm trying to integrate PHPMailer as I was having problems receiving mail natively. Here is my code: <?php include("./header.inc"); $success_message = "<h3 class='success'>Thank you, your message has been sent.</h3>"; $success = false; // we assume it and set to true if mail sent $error = false; // set and sanitize our form field values $form = array( 'name' => $input->post->name, 'email' => $input->post->email, 'phone' => $input->post->phone, 'subject' => $input->post->subject, 'level' => $input->post->level, 'hours' => $input->post->hours, 'message' => $input->post->message ); $required_fields = array( 'name' => $input->post->name, 'email' => $input->post->email, 'subject' => $input->post->subject, 'level' => $input->post->level, ); // check if the form was submitted if($input->post->submit) { // determine if any fields were ommitted or didn't validate foreach($required_fields as $key => $value) { if( trim($value) == '' ) { $error_message = "<h3 class='error'>Please check that you have completed all the required fields.</h3>"; $error = true; } } // if no errors, email the form results if(!$error) { $to_name = "To name"; $to = "recipient@email.com"; $subject = "Contact Form Request"; $from_name = "From Name"; $from = "sender@email.com"; foreach($form as $key => $value) $message .= "$key: $value\n"; require_once("./scripts/PHPMailer/class.phpmailer.php"); require_once("./scripts/PHPMailer/class.smtp.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "ssl"; // sets the prefix to the servier $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail->Port = 465; // set the SMTP port for the GMAIL server $mail->Username = "username"; // GMAIL username $mail->Password = "password"; // GMAIL password $mail->FromName = $from_name; $mail->From = $from; $mail->AddAddress($to, $to_name); $mail->Subject = $subject; $mail->Body = $message; $mail->Send(); if ($mail->Send()) { $success = true; } } } ?> <?php if(!$success) { ?> <?php if($error) { echo $error_message; // or pull from a PW field } ?> <p id="contact_header">If you'd like to get in touch regarding tuition, please use the form below.</p> <div id="contact_aside"> <h6>Or you can find me, here: </h6> <ul> <li>Skype: <?php echo $page->skype_name; ?></li> <li><a href="<?php echo $page->fb_url; ?>" target="_blank">Facebook</a></li> <?php if ($page->twitter_url) { echo "<li><a href='$page->twitter_url' target='_blank'>Twitter</a></li>"; } ?> </ul> </div><!-- /#contact_aside --> <div class="clear"></div><!-- /.clear --> <form action="./" method="post" id="contact_form"> <fieldset class="first"> <h6>About yourself: </h6> <label for="name">Your name: (required) </label> <input type="text" name="name" autofocus> <label for="email">Your email: (required) </label> <input type="email" name="email"> <label for="phone">Your phone number: </label> <input type="phone" name="phone"> </fieldset> <fieldset> <h6 class="mt60">Your tuition: </h6> <label for="subject">Subject: </label> <select name="subject" id="subject" /> <?php foreach ($page->subject_options as $subject) { echo "<option>$subject->subject_option</option>"; } ?> </select> <label for="level">Level: </label> <select name="level" id="level" /> <?php foreach ($page->level_options as $level) { echo "<option>$level->level_option</option>"; } ?> </select> <label for="hours">Hours per week: </label> <input type="number" min="1" max="40" value="2" name="hours"> </fieldset> <div class="clear"></div><!-- /.clear --> <fieldset class="full"> <label for="message">Additional information: </label> <textarea name="message" cols="30" rows="10"></textarea> <input type="submit" name="submit" value="submit" id="submit"> </fieldset> </form> <div class="clear"></div><!-- /.clear --> <?php } else { echo $success_message; ?> <p>Please click <a href="<?php echo $config->urls->root; ?>">here</a> if you would like to return to the homepage.</p> <?php } ?> <?php include("./footer.inc"); ?> At present when the form is submitted, the page seems to think about something for a while then the page gets reloaded exactly the same as before. Thanks in advance if you have any ideas.
  17. Just wanted to say thanks to all of you for helping me out with this, it works perfectly as expected, if a user has the credentials I can send him off to another template with private information and if they don't they'll just see the normal page. The client can add all the necessary information under one entry so this is very powerful and easy at the same time!
  18. Hi Sinnut, yep I'm very new to PHP, I'm more familiar with ExpressionEngine syntax so this is all relatively new to me! Thanks for the pointers.
  19. Everfree, there seem to be many different responses to this. It would be great if all the possibilities were listed in one reference page. Perhaps with the method and the types of field to which it applies.
  20. Thanks Ryan that sounds exactly what I was looking for. So in theory I could put an include within an if urlSemgent test and output a whole new template. This would basically allow me to replicate EE's templating system somewhat?
  21. Wow thanks Ryan though it's a bit over-my-head in PHP terms so will try and get learning before I put the code in! I hadn't even heard of "do" or "shift" before!
  22. Sorry, I meant it start a drop down list then I hit Tab on one of the autocompletes, it completes the title field but not the URL - I'm not sure if it's even an issue, it's just caught me out a few times!
×
×
  • Create New...