Jump to content

Claus

Members
  • Posts

    94
  • Joined

  • Last visited

Everything posted by Claus

  1. Okay, so I figured it out. I have individual products as repeater fields on a given product page, and each of these items have a full name. So I went to line 219 of ShoppingCart.module and replaced the section with this: $title = $product->sc_name; … and I now get the correct title of each item.
  2. Okay, one bonus question: I can’t figure out how to get the names of the repeater items to appear after I have added them to the shopping cart. Instead I get the title of the page, which I am guessing ShoppingCart presumes is the product proper, for each of the added items. How can get the name of each added item instead? I’ve tried to see what I could find in the module, but only got as far as this: https://github.com/apeisa/Shop-for-ProcessWire/blob/master/ShoppingCart.module#L219 and as I read it, the module should automatically construct the names from the page/product name plus the repeater-name (l. 222).
  3. Bingo! Thank you very much, this is awesome
  4. Hi there! I’m using Apeisa’s ShoppingCart module to do a little shop. I have pages each with a range of products as repeater items. These items have different prices (package deals, individual products and so on). They all render with correct names and prices. So far so good! Now the issue: When I add one or more products to the cart I get the $title of the $page instead of the product name, and the price is set to the price of the first product on the page no matter which product I add to the cart. So I’m doing something wrong. Here is the code I’m using: // Primary content is the repeater fields of "sc_item" $contentThree = ''; //sc_item is my repeater field foreach ($page->sc_item as $product) { $contentThree .= "<span class='sc_item'>" . $product->sc_name . "</span></br>"; $contentThree .= "<span class='sc_price'>" . $modules->get( "ShoppingCart" )->renderPrice( $product->sc_price ) ."</span> excl. BTW (VAT)"; $contentThree .= "<span class='sc_add'>" . $modules->get("ShoppingCart")->renderAddToCart(). "</span>"; } $contentThree .= $modules->get("ShoppingCart")->renderCart(); Can anyone point me in the right direction?
  5. Awesomeness, it works! Thanks diogo!
  6. Bingo! Being the n00b that I am I had not considered that possibility Thanks fokke!
  7. That was also what I was thinking, but PW gives me the same error: Undefined variable: template … if I put it in _main.php. I’m quite puzzled by this one.
  8. I’m trying to use the $template->name by declaring this in "_init.php": $cssFile = $template->name . ".css"; … and I then have this in "_main.php": // Use custom CSS-file if that file exists. <?php if(is_file($config->paths->templates . "styles/$cssFile")) { echo "<link rel='stylesheet' type='text/css' href='{$config->urls->templates}styles/$cssFile' />"; }; ?> However PW throws this notice: Notice: Undefined variable: template in /Users/claus/Sites/ProcessWire/site/templates/_init.php on line 29 Notice: Trying to get property of non-object in /Users/claus/Sites/ProcessWire/site/templates/_init.php on line 29 // Use custom CSS-file if that file exists. Do I have to define $template->name? I thought that was a built-in function?
  9. Hmm, that didn’t change anything as far as I can tell.
  10. Hello there! I have a question regarding the "renderNav" function used in the ‘intermediate’ site-profile. I have a multi-level menu system going by using the renderNav function, and I’d like to extend the default "renderNav" function to also mark all the parents of any given page with "current". I think I have to modify this line from the "renderNav" function: $out .= $item->id == wire('page')->id ? "<li class='current'>" : "<li>"; … specifically adding something along the lines of foreach parent of the itemid "<li class='current'>" else "<li>", but is there a neat way of putting that into the existing line? Or how would you do it? Thanks!
  11. Thanks for your help totoff and Bernhard!
  12. Okay, so a bit more fiddling brought me to this solution which feels somewhat ‘hacky’ to me, so do feel free to suggest improvements. I made special templates for those category-pages that were just placeholders for deeper content and contained no content of their own, eg. ‘Products’ and ‘News’ in the top level, ‘Apple’, ‘Banana’, and ‘Orange’ in the secondary level. For the category-pages that needed three levels to get to an actual content page I made a template with: <?php $session->redirect($page->child->child->url); … and then assigned ‘Products’ and ‘News’ to this template. And for the the category-pages that needed two levels to get to an actual content page I made a template with: <?php $session->redirect($page->child->url); … and then assigned ‘Apple’, ‘Banana’, and ‘Orange’ to this template. This works! Albeit with the annoyance of these redirects loading a page for each ‘step’ down to the final content-page. This is why I call it ‘hacky’.
  13. Hi totoff The purpose of the redirect would be to avoid that users would click on ‘Products’ in the first menu-column, and then see a list of products in the second menu-column but without any content. Without a redirect that would look like so when clicking on ‘Products’: Home Apple [EMPTY] *Products Banana News Orange About Contact And then clicking on ‘Apple’ would look like so: Home *Apple Description [EMPTY] *Products Banana Features 1 News Orange Features 2 About Features 3 Contact The user would have to click through the hierarchy of the primary, secondary, and tertiary menu-columns to finally get to see the content: Home *Apple *Description *Description for ‘Apple’… *Products Banana Features 1 News Orange Features 2 About Features 3 Contact This is what I want to avoid by having a click on a menu-item in the primary menu, automatically point to the first-found ultimate page of that given tree.
  14. Hello guys! Thank you for your replies. To make sure we understand each other, here is the site structure: - home |- products | '- apple | | |- description page | | |- features 1 | | |- features 2 | | '- features 3 | | | |- banana | | |- description page | | |- features 1 | | |- features 2 | | '- features 3 | | | '- orange | |- description page | |- features 1 | |- features 2 | '- features 3 | |- news | |- news1 | '- news2 | |- about '- contact In the design of the site I have columns as menus, where the left column is the menu for the root-level, the next column the menu for the second level, and finally a third column as the menu for the third level. After that I have the main content. The menus two and three are only rendered if needed. Eg. for the ‘Contact’ page there is only the first column shown, and then the content for the Contact page. For the ‘News’ page I have the first and the second column menu, and then the content. For the ‘Product’ page I have all three columns showing, and then the content. It should look like this, if the user clicks on ‘Products’ in the first column menu: Home *Apple *Description *Description for ‘Apple’… *Products Banana Features 1 News Orange Features 2 About Features 3 Contact To make this happen I’ve made the following system, starting with the ‘_init.php’: $menuLevel = count($page->parents); $homepage = $pages->get('/'); Then I’m using the ‘renderNav’ function in the ‘_func.php’ Then I’m doing custom template files for the pages, here is eg. the product template: // The secondary and tertiary menus if($menuLevel >= '1') { $secondaryNav = renderNav($page->rootParent, 1); } if($menuLevel >= '2') { $tertiaryNav = renderNav($page->siblings, 1); } // Primary content is the page's body copy $contentThree = $page->body; And then finally it is all rendered in the ‘_main.php’ where the rendering of the menu-columns are dependant on whether the page template needs them. <body> <!-- primary navigation --> <div id="primaryNav"> <ul class='primaryNav'> <?php // top navigation consists of homepage and its visible children foreach($homepage->and($homepage->children) as $item) { if($item->id == $page->rootParent->id) echo "<li class='current'>"; else echo "<li>"; echo "<a href='$item->url'>$item->title</a></li>"; } // output an "Edit" link if this page happens to be editable by the current user if($page->editable()) echo "<li class='edit'><a href='$page->editURL'>Edit</a></li>"; ?> </ul> <form class='search' action='<?php echo $pages->get('template=search')->url; ?>' method='get'> <input type='text' name='q' placeholder='Search' value='<?php echo $sanitizer->entities($input->whitelist('q')); ?>' /> <button type='submit' name='submit'>Search</button> </form> </div> <!-- end primary navigation --> <!-- content with one level of navigation --> <?php if (isset($contentOne)) { echo "<div id='contentOne'>"; echo $contentOne; echo "</div>"; } ?> <!-- end content with one level of navigation --> <!-- secondary navigation --> <?php if (isset($secondaryNav)) { echo "<div id='secondaryNav'>"; echo $secondaryNav; echo "</div>"; } ?> <!-- end secondary navigation --> <!-- content with two levels of navigation --> <?php if (isset($contentTwo)) { echo "<div id='contentTwo'>"; echo $contentTwo; echo "</div>"; } ?> <!-- end content with two levels of navigation --> <!-- tertiary navigation --> <?php if (isset($tertiaryNav)) { echo "<div id='tertiaryNav'>"; echo $tertiaryNav; echo "</div>"; } ?> <!-- end tertiary navigation --> <!-- content with three levels of navigation --> <?php if (isset($contentThree)) { echo "<div id='contentThree'>"; echo $contentThree; echo "</div>"; } ?> <!-- end content with three levels of navigation --> </body> (I have to define ‘primaryNav’, ‘secondaryNav’, ‘tertiaryNav’, ‘contentOne’, ‘contentTwo’ and ‘contentThree’ in separate divs because the menu-columns are ‘position: fixed;’) Now I tried to use the $session->redirect($page->child->child->url); in the products template, but still gives me that blank page, and it still seems to load a page at each step if the path until it gets to the first child. If I have this re-direct enabled and click ‘View’ from the admin, I also get the blank page, so I have a feeling that I’m “sawing over the branch I’m sitting on” somewhere in the chain of templates. I just can’t figure out where I’m going wrong.
  15. +1 for Dash.
  16. Hello everybody! This is my first foray into the world outside Wordpress, and ProcessWire looked like it would be able to do what I want to build without overhead, and at the same time an opportunity to learn. I have no coding skills at all. I am diving head-first into the wall here, so bear that in mind please. I have a few questions on the site I’m working on. I’m using the ‘intermediate edition’ where ‘_main.php’ renders some divs of menus and content conditionally, if the variables are declared in the templates (that are loaded before the _main.php). The home is a column of sub-pages like this: Home Products News About Contact … Under the Products I have several sub-pages with products, which in turn have sub-pages of their own. I’d like to have a click on the Products to automatically link to the first product’s first child-page, so I saw this in another thread: $session->redirect($page->child->url); But when I place it in my Products template, and click on ‘Products’ in the main menu, my browser redirects one level at the time, until it gets to the first child of the first product, but the page is then blank (view source shows that the page is empty). The URL looks correct, and if I turn off the redirect and load the very same URL then the site renderes as expected. So my question is what I’m doing wrong here? Additionally I’d like to ask if there is a way to make a redirect go directly to the first child of the first product-page, instead of going in steps one level at the time? ***** Another question entirely is that I’m using the ‘renderNav’ in ‘_func.php’ to render my menus, and in the sub-menus I get the name of the sub-menu at the top of the menu like this: Products Apples Pears Oranges … How do I remove the ‘Products’ from the top? ***** Thanks! Claus
×
×
  • Create New...