Jump to content

ZionBludd

Members
  • Posts

    42
  • Joined

  • Last visited

Everything posted by ZionBludd

  1. Hi, on my website I have the comments system implemented across each store page. I am wanting to see if their is a built in function to allow to bring in all of the comments for a particular brand into one page Store Listing 1 (Belongs to store brand XYZ) Store Listing 2 (Belongs to store brand XYZ) Store Brand Listing Page (Lists all of the store listings, plus all of the comments from Store listing 1 & Store Listing 2)
  2. Hi Team, I am wondering how I would go about logging an entry either in the database (e.g. a field) or through the $log function? My site is a price comparison tracker and I am hoping to be able to present data to people advertising on my site if they click on a link? Another solution I guess I could use would be Google Analytics, but would be nice to have something inside PW.
  3. Hi, I'm having an issue where my form won't respond to my post form if I'm on any other page other than Page 1 of a set of pagination results. Is this a limitation of pagination? Has anyone else came across this?
  4. Thanks heaps for your suggestions, Robin. I am looking to improve the structure over the weekend & will take these on board Thanks tpr, Will look into this!
  5. Thanks, Gideon, What I was hoping to do was to perform the same search but limit it at the lowest and highest ends of the spectrum (e.g. Highest price and lowest price). Does that make sense?
  6. Hi Gideon, the price field that it's been sorted by is the price field name.
  7. Hi Team, I am having trouble sorting prices in my foreach loop and am wondering is becasuse my price field is a text field and not a number field. My code is <?php $item_title = $item->title; $items = $pages->find ("template=Listing, limit=15, sort=title"); foreach ($items as $item😞?> <tr> <td>{item.brand}</td> <td>{item.model}</td> <td> <?php $item_title = $item->title; $store_price = $pages->find ("template=PriceSpy, sort=price, title=$item_title, limit=1") ; foreach ($store_price as $price) :?> {price.price} <?php endforeach ;?> </td> <td> <?php $item_title = $item->title; $store_price = $pages->find ("template=PriceSpy, sort=-price, title=$item_title, limit=1") ; foreach ($store_price as $price) :?> {price.price} <?php endforeach ;?> </td> </tr> <?php endforeach ;?> The offending page is this one: https://www.vapeprices.co.nz/price-guide/. Whereas you can see the Low and High columns are just not making sense I would really appreciate any help.
  8. Hi All, I am wondering if anyone has come up with an easier way of merging their local environment with the live production environment. For instance, my thinking would be to use Site Profile Exporter, install Processwire in the main directory of the live environment & install. Just to clarify, This is if I am doing a lot of structural changes obviously to both the template fields level and the templates themselves. Otherwise, it would be just the normal (keeping two copies in sync and uploading etc). Does anyone have any solutions?
  9. Hi All, I am experiencing issues in including files that are in multiple sub directories. They don't seem to load or break the File Compiler Tags module. My syntax is as follows <?php require 'src/components/breadcrumbs.php'; require 'src/components/topmeta.php'; require 'src/components/page.php'; ?> Anyone else have issues relating to this? I'm using the latest PW build.
  10. Hi All, I am wondering if anyone has a solution to my problem. I have a website that I have at a DomainA.com, but I am wanting all templates/static assets (such as images uploaded by the user, PW, etc) to be assets.domaina.com Is this possible? From what I've read in the forums - you need to use some special htaccess code, but the posts are from a few years ago.
  11. Hi guys, I am wondering how I deal with this error message. Whenever I am trying to save a page I am getting this error when someone enters the same name in the "name" textbox. Here is my code <?php if ($input->post->reviews || $input->post->name) { // Save in the ProcessWire page tree; map submission to the template fields $np = new Page(); // create new page object $np->template = $templates->get("reviews"); $np->parent = $pages->get("/reviews/"); $name = $sanitizer->text($input->post->name); $email = $sanitizer->text ($input->post->email); $review = $sanitizer->text ($input->post->review); // Match up the sanitized inputs we just got with the template fields $np->of(false); $np->title = $name; $np->page_id = $page->id; $np->name = $name; $np->email = $email; $np->review = $review; $np->save(); } ?>
  12. Thanks for all of your help. I managed to get the desired end result using Ryan's example:
  13. Just curious, if I had a select input by the name of "type" - Can I call that directly and output the options
  14. Thanks for your reply, can you give me an example of how I might implement this?
  15. Hi, I am wondering if there is a better way to output a field's options Currently I am basically adding types as they are required, but I can see the types growing - and wondering if I can call directly from the field? <select name="product_type" class="form-control" style="font-size:9pt"> <option value=""><?php echo $NO_SELECT_PRODUCT; ?></option> <option <?php if ($pt == "Starter Kits"){echo 'selected';};?> value="Starter Kits">Starter Kits</option> <option <?php if ($pt == "Advanced Kits"){echo 'selected';};?> value="Advanced Kits">Advanced Kits</option> </select>
  16. Thanks so much for all of your responses. Such an amazing community. I've done a-lot of reading, and debugging with TracyDebugger and this what what I've come up with <?php $limit = null; $sort = null; $template = null; $kit_type = $session->get('search_type'); if ($page->path == "/kits/starter-kits/") { if ($input->post->product_brand_name || $input->post->limit || $input->post->product_type || $input->post->product_port_location) { $session->set ('template', 'products'); $session->set ('limit', $input->post->limit); $session->set ('product_type', $input->post->product_type); $session->set ('product_brand_name', $input->post->product_brand_name); $session->set ('port_location', $input->post->product_port_location); // Build selector $selector = "template=$session->template, product_brand_name=$session->product_brand_name, product_port_location=$session->port_location,limit=$session->limit, product_type=$session->product_type"; var_dump ($selector); } else { $session->set ($product_type , 'Starter Kits'); $selector = "template=products, sort=name, product_type=$session->product_type"; echo "<pre style='padding:10pt'>"; echo "Default Starter Kits landing settings"; echo "<br>"; var_dump ($selector); echo "</pre>"; } } elseif ($page->path == "/kits/advanced-kits/") { if ($input->post->product_maker || $input->post->limit || $input->post->product_type || $input->post->product_port_location) { $session->set ('template', 'products'); $session->set ('product_maker', $input->post->product_maker); $session->set ('limit', $input->post->limit); $session->set ('product_type', $input->post->product_type); $session->set ('port_location', $input->post->product_port_location); // Build selector $selector = "template=$session->template, product_port_location=$session->port_location, product_maker=$session->product_maker, limit=$session->limit, product_type=$session->product_type"; var_dump ($selector); } else { $session->set ('product_type' , 'Advanced Kits'); $session->set ('product_maker' , ''); $selector = "template=products,sort=price, product_type=Advanced Kits"; echo "<pre style='padding:10pt'>"; echo "Default Advanced Kits landing settings"; echo "<br>"; var_dump ($selector); echo "</pre>"; } } elseif ($page->path == "/kits/advanced-kits/") { if ($input->post->product_maker || $input->post->limit || $input->post->product_type || $input->post->product_port_location) { $session->set ('template', 'products'); $session->set ('product_maker', $input->post->product_maker); $session->set ('limit', $input->post->limit); $session->set ('product_type', $input->post->product_type); $session->set ('port_location', $input->post->product_port_location); // Build selector $selector = "template=$session->template, product_port_location=$session->port_location, product_maker=$session->product_maker, limit=$session->limit, product_type=$session->product_type"; var_dump ($selector); } else { $session->set ('product_type' , 'Advanced Kits'); $session->set ('product_maker' , ''); $session->set ('limit', '10'); $selector = "template=products,sort=price, limit=$session->limit, product_type=Advanced Kits"; if ($user->isSuperuser()){ echo "<pre style='padding:10pt'>"; echo "Default Advanced Kit landing settings"; echo "<br>"; var_dump ($selector); echo "</pre>"; } } } elseif ($page->path == "/kits/intermediate-kits/") { if ($input->post->product_maker || $input->post->limit || $input->post->product_type || $input->post->product_port_location) { $session->set ('template', 'products'); $session->set ('product_maker', $input->post->product_maker); $session->set ('limit', $input->post->limit); $session->set ('product_type', $input->post->product_type); $session->set ('port_location', $input->post->product_port_location); // Build selector $selector = "template=$session->template, product_port_location=$session->port_location, product_maker=$session->product_maker, limit=$session->limit, product_type=$session->product_type"; var_dump ($selector); } else { $session->set ('product_type' , 'Intermediate Kits'); $session->set ('product_maker' , ''); $session->set ('limit', '10'); $selector = "template=products,sort=price, limit=$session->limit, product_type=Intermediate Kits"; if ($user->isSuperuser()){ echo "<pre style='padding:10pt'>"; echo "Default Intermediate Kit landing settings"; echo "<br>"; var_dump ($selector); echo "</pre>"; } } } ?> However, haven't been able to implement post resubmission errors (Post Get Redirect method) And I'm having trouble with removing the product_brand_name selector when it's not selected in my form.
  17. Hi, I am currently in the process of converting over some friends code from pure PHP code to the PW API. However, I've come into a road block with $_SESSION. Can someone explain to me the PW equivalent of PHP's $_SESSION. What I am doing below is preventing the page doing another post on a page refresh, using the Post/Redirect/Get method. <?php //var_dump($_POST); if($_SERVER["REQUEST_METHOD"] == "GET"){ //check for filter action if(isset($_SESSION["filter"])){ $template = $_SESSION["filter"]; //this is your templates //things should just work. $_SESSION["filter"] = null; } else{ if ($page->id == "1019") { $template = "product_maker=NULL"; $template = "template=products, product_type=Starter Kits,sort=name"; // Defaults for fields $_SESSION["product_type"] = $_SESSION["product_maker"] = $_SESSION["limit"] = null; } } if(isset($_SESSION["product_type"])){ $product_type = $_SESSION["product_type"] ; } if(isset($_SESSION["product_maker"])){ $product_maker = $_SESSION["product_maker"] ; } if(isset($_SESSION["has_images"])){ $has_images = $_SESSION["has_images"] ; } if(isset($_SESSION["limit"])){ $limit = $_SESSION["limit"] ; } var_dump($_SESSION["product_type"]); } else if($_SERVER["REQUEST_METHOD"] == "POST"){ if ($input->post->$sanitzer->product_type || $input->post->has_images || ($input->post->$sanitzer->product_maker || ($input->post->limit))) { $_SESSION["product_type"] = $product_type = $input->post->product_type; $_SESSION["product_maker"] = $product_maker = $input->post->product_maker; $_SESSION["has_images"] = $has_images = $input->post->has_images; $_SESSION["limit"] =$limit = $input->post->limit; $template = "template=products, has_images=$has_images, product_maker=$product_maker, limit=$limit, product_type=$product_type"; $template; $_SESSION["filter"] = $template; } elseif ($input->post->has_images) { $template = "template=products"; } //else { // $product_type = $input->post->product_type; //} $_SESSION["filter"] = $template ; header("Location: ".$_SERVER['REQUEST_URI']); exit(); //redurect to self. } ?>
  18. Hi, I am wondering if someone can help me out with getting the count of the comments of a page? I am using Ryan's comments module as a reviews system for my site and would like to display the count of the comments per page, as below The shops part that you see above is something similar to this <?php $set_page = $page->title; $count = $pages->count("template=prices, title=$set_page"); echo $count; ?>
  19. Thanks so much for your efforts! You put me in the right direction, I ended up going for the page create function vs storing in the user->favs way. Manly because my friend who is helping me with this is a software developer and he stays clear of frameworks. This is my code for detecting the input button. <?php if ($input->post->add_fav) { // Save in the ProcessWire page tree; map submission to the template fields $np = new Page(); // create new page object $np->template = $templates->get("Favorites"); $np->parent = $pages->get("/favorites/"); ?> On the results page in each item I have the following code <form action="./" method="post"><button type="submit" value="{dbResult.id}" name="add_fav">Add Favorite</button> </form> And then finally this is the most stop gap measure system to actually view the favorites, and I'm sure you'll be able to point out that it is very prone to bugs and security holes <?php $id = $user->id ; $get_favs = $pages->find("template=Favorites, user_id=.$id."); foreach($get_favs as $fav) { echo "<li><a href='$fav->url'>$fav->product_id</a></li>"; } ?> Thanks again for your help, What do you think? Are you shuddering
  20. Thanks so much for your help kongondo. I am currently debugging my site, and can't output the user favorites or get it to save to the database. This is after adding the field favs to the user template. I'm sure I'll get it to work eventaully. Edit: Would cookies be another way to accomplish this?
  21. Hi All, I am wondering if you could provide input on the best way an item as a user favorite. I am setting up a price comaprison website, and have most of the logic done for the site. Search results, listing page, login/logout, search, etc. It's all looking pretty good. However someone has suggested to me that users might like to save an item as a favorite. So my idea behind that was to have a button on each of the grid items in the search results page. This is my search results page code with the button within the item. <form id="add_fav" name="add_fav" autocomplete="off" accept-charset="utf-8" action="./" method="post"> <button class="wish_btn" name="add_fav">Add Fav</button> </form> Where the business logic is on the page, this is what I have so far - I just don't know how to align an item to a user. $log->save ('pageview', 'testing'); function clense_input($data){ $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $sort = "title"; // Logic for favorites if ($_SERVER["REQUEST_METHOD"] == "POST") { if (isset($_POST['add_fav'])) { $favs = $sanitizer->text($_POST['add_fav']); if(!empty($favs)){ $ticket = $pages->get($favs); // Set page name if($favs != null){ $favs->of(false); $favs->fav_title = $page->user->name; // Save username $favs->fav_title = $page->title->id; // Save page id to favs list $favs->save(); echo "Fav saved."; } } } }
  22. Hi guys, I'd really appreciate some help from you. I am wondering how I would about using the Selector field type within a repeater. It seems kinda bad design to have multiple selectors (e.g. Grid 1, Grid 2, Grid 3) when I could use a repeater for it. Using Ryan's example, I have managed to get my repeater to work foreach($page->grid_repeater as $grids) { echo "<h2>{$grids->grid_type}</h2><p>"; echo " }
×
×
  • Create New...