Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by ZionBludd

  1. Thanks a lot for this - It has helped immensely. Also with my overall understanding of PW now. One thing I am curious of - Is it possible to display "Saved" and the then redirect to another page. Each time I try a $session->redirect, it seems to pick it up regardless if anything has been passed thru the form.
  2. This a great example. In my case, I am building a lost property register that all the staff will have access to. I'm wanting them to be able to goto a page and be able to edit/update the contents of that specific page - e.g. Specific fields - via a form on that page - not create more pages (In this case)
  3. Thanks alot for your reply. I've seen your work around the forums alot! I picked up $u from a code example in the forums. If I am wanting to just simply save the data that is coming from my form, what do I need to put in the first ($) field.
  4. I've been trawling through the forums and can't seem to find a working example to fix my problem. I have a field called "lp_item" that is displayed on a page, and I want the user to be able to edit this field from the frontend. I've seen Soma's example and also Frendi, but quite like the idea of been able to use the API to do this. Here is my form code <form class="form form-control" accept-charset="utf-8" action="./" method="post"> <label for="lp_item">Lost Property item <input type="text" name="lp_item"/> <input type="submit" name="form_submit" value="Submit"/> </form> And I have this below the form <? if($input->post->form_submit) { $u->save(lp_item); $u->save(); $session->redirect('./'); } else { echo "test"; } ?> Keep getting a Error: Call to a member function save() on a non-object Any ideas, please?
  5. I'm using the comments module as the basis for a simple reviews system. Pretty basic at the moment... I'm having issues getting it to display a "No reviews found message" Here is my existing code: <? // if ($page->enable_reviews) $limit = 10; $start = ($input->pageNum-1) * $limit; // Status 1 means approved $selector = "page=$page, status=1, sort=-created, start=$start, limit=" . ($limit+1); // find the comments. replace "comments" with the name of your comments field $comments = FieldtypeComments::findComments("reviews", $selector); // output the comments //if ($comments->status = 1) echo $comments->render(array('headline' => '<h4><i class="fa fa-star"></i> Reviews</h4>', )); // output the pagination links if($input->pageNum > 1) echo "<a href='./page" . ($input->pageNum-1) . "'>Back</a> "; if(count($comments) > $limit) echo "<a href='./page" . ($input->pageNum+1) . "'>Next</a>"; if ($selector->status ==0) ; echo "Test"; ?> I've tried if ($page->$reviews >1) then display, but doesn't seem to work... . Anyone using the comment module have any idea on how to get this to work?
  6. Thanks a lot! This reduced alot of lines of code And for those interested, this is what the end result was: http://imgur.com/Pip0BMu
  7. Sorry have updated my original code. Wasn't on my machine when posting this
  8. Hi guys. I am wanting to do breadcrumbs based on the page matching a condition. However, I'm wondering if there is a way for me to reduce the number of if else statements. Here is my code. <? if ($page->city == 'Auckland' { $setcity = 'Auckland'; echo "<span class='topNav'> <a class='' href='/gyms' title='Gyms'> <i class='fa fa-chevron-left'></i></span>"; echo "All Gyms</a>"; echo "<span class='topNav'> <a class='' href='/gyms/auckland-gyms/' title='Auckland Gyms'> <i class='fa fa-chevron-left'></i></span>"; echo "Auckland Gyms</a>"; echo "<span class='topNav'> <strong> <i class='fa fa-chevron-right'></i></span>"; echo $page->title; echo "</strong></small>"; } elseif ($page->city == 'Christchurch') { $setcity = 'Christchurch'; echo "<span class='topNav'> <a id='$page->id' class='' href='/gyms' title='Gyms'> <i class='fa fa-chevron-left'></i></span>"; echo "All Gyms</a>"; echo "<span class='topNav'> <a id='$page->id' class='' href='/gyms/christchurch-gyms/' title='Christchurch Gyms'> <i class='fa fa-chevron-left'></i></span>"; echo "Christchurch Gyms</a>"; echo "<span class='topNav'id='$page->id' > <strong> <i class='fa fa-chevron-right'></i></span>"; echo $page->title; echo "</strong></small>"; } ?> Where $setCity is used <span class="pull-right hidden-sm hidden-xs"> <? // Populate a random gym in the same city $getRandomPages = $pages->find("template=listing-gym, city=$setcity, sort=random, limit=1")->first(); if($getRandomPages->id) { $q = $getRandomPages->title; // example field $a = $getRandomPages->url; // example field echo " <a title='$q' href='$a'><i class='fa fa-random'></i> Random Gym</a>\n"; } ?> Essentially all I am wanting to do is print a breadcrumb trail if the city of the listing is equal to the city name. Edit: Sorry... Was not on my main machine when posting the original code. Updated.
  9. Thanks for your reply, Peter! The link that you provided fixed the problems. How would I limit the results to 10, as well as use the limit=n feature?
  10. Hi All, my selector appears to break when on pagination pages... E.g. page/page2 Any ideas as to why it would break? Here is my code: <div class="well" style="background-color:#fff"> <div style="border-bottom:1px solid #ededed; padding-bottom:5pt"> <strong><i class="fa fa-star"></i> Top Rated Gyms</strong> </div> <div style="padding-top:5pt"> <? $pa = $pages->find("rating=3|4|5, template=listing-gym, sort=random, limit=10"); foreach ($pa as $p) { echo "<a style='display:block' class='underline' href='$p->path'>$p->title</a>"; } ?> </div> </div>
  11. I am wanting to save pages via a form input. I've done a fair amount of searching, and am struggling to find a working solution. Primarily my knowledge falls under web design, and this web development (PHP, PW, etc) is new territory for me. If i was starting below, how would I tie it all together with a form? $p = new Page(); // create a new page $p->template = 'reviews_template'; // choose template $p->parent = wire('pages')->get('/gyms/'); // choose parent page $p->title = $sanitizer->text($input->get->title); // clean user input and set title $p->a_field = $sanitizer->text($input->get->field); // clean user input and set a custom field $p->save(); // save the page
  12. Thanks. I had a look at the page on ternary operators and definitely find it looks easier. I am forever mucking up my if else statements, so this might be a better way.
  13. Thank you. This worked. Still learning PHP, hence the messy code
  14. I am wondering how I would go about getting PW to put a class="list-group-item active" class onto the page that is active. Here is my code currently <?php //$getStaticPages = $pages->get("/about"); $staticPages = $about->children("sort=name"); foreach($staticPages as $staticPage) {?> <li class="list-group-item"><a href="<?=$staticPage->url?>"><?=$staticPage->title?></a></li> <?}?> I'd appreciate any help
  15. Hi everybody. I just wanted to start by saying what a great support forum this is so far, was blown away by my first post! I have since managed to get a lot of my project working, but am now stuck on a pretty major part. The reviews system. This was before handled by a plugin (Wordpress). My website is a reviews website that focuses on the fitness industry... The website consists of three parts Homepage Search Results Page Listing Page I am wanting to implement a reviews section on each page, basically defined by the title of the page. I have created for this purpose my own table, independent of PW, just due to the fact I suspect this will be a very large database table and don't want to have stability issues later on down the track. Should I be using PW's field_ tables or? Here is my current code I am very much at the beginning of learning PHP, and would love some guidance on how to move forward. Cheers
  16. I just want to say THANK YOU to everyone who posted, it's made my day. What a great community this project has. The location tag mentioned, is that referring to a field (Custom field they are called in WP)
  17. Hi All, forgive me for my question. I am building a reviews website, where people are able to submit listings and reviews of particular items. My website or "app" functions as below: Homepage Simple static page with a hero/search box, etc Search Results Page One of the core pages, currently using a solution where WP_Query searches for results and returns them. Currently controlled by WP_Query search command, bringing back results. I've looked up how to do this PW, and the only way is via {foreach} - is this correct? Or is there a better way? Listing Page Displaying a whole bunch of custom fields I've grown to dislike Wordpress simply because it feels sluggish and is too much for what I want to do - which is accept data from users, enter some data myself, and show that data. It's a very basic reviews website, nothing too fancy IMO. My main concerns about shifting from WP to PW is the search results page - Is there more control over the results than using foreach. Code i've managed to get working so far - but for instance, what If I need to sort the items by location, etc, etc? <?php $gyms = $pages->find("parent=/gyms/"); foreach($gyms as $gym) ?> <div class="panel panel-default panel-shadow" style="margin-bottom:10pt"> <div class="panel-body"> <h4 class="margin-t-none"> <?php $li .= "<a href='{$gym->url}'>{$gym->title}</a> $page->gymtitle "; echo $li ? "<ul>$li</ul>" : "<h1>No entries found</h1>"; ?> </h4> </div></div> Quite late at night over here in NZ. Excuse the grammar.
  • Create New...