-
Posts
4,632 -
Joined
-
Last visited
-
Days Won
55
Everything posted by apeisa
-
Getting a specific repeater row and its fields
apeisa replied to landitus's topic in General Support
$color = $pages->get("template=color-option, name=red"); // Or where you keep your colors actually // Just a placeholder $p = new NullPage(); // Loop all your repeater rows foreach($page->repeaters as $rep) { // Check for the wanted color if ($rep->color == $color) { $p = $rep; // And when found, put it to our variable continue; // No need to go further } } if ($p->id) { echo $p->img->url; } else { echo "No $color chairs found"; } I read and wrote pretty quickly, but hopefully above could be in some help? -
That is some very strange stuff, since i would assume cloning a field is mostly a backend process. If you duplicate/clone file field on Safari or Firefox, does that cloned field work on Chrome? Or is it broken on every browser? And clone with Chrome, works everywhere? Are you using the default theme or some alternative?
- 8 replies
-
- uploads
- file-uploads
-
(and 4 more)
Tagged with:
-
At the moment - if I remember correctly - answer to both is no. Both have been discussed and will most probably get implemented at some point.
-
Selector to imitate MySQL "IN()" statement
apeisa replied to choppingblock's topic in API & Templates
I am little confused what you are trying to achieve and why it doesn't work. I think part of the confusion is that I don't understand how you have setup your products and categories and how they relate each others. In most common "multicategory" setup product has field called "category" that allows one or more categories. Then the selector is simple as this: $pages->find("category=$categories"); -
I just (like 5 mins ago) implemented "Most Viewed Pages" widget for a client. I used Wanzes excellent ProcessGoogleAnalytics module and it was easy enough pull data when it was first setup. It might be that this is not a fit for your project Martijn (if you need the data for selectors for example), but this is how I did it: $pga = wire('modules')->get("ProcessGoogleAnalytics"); $ga = new GoogleAnalyticsAPI(); $ga->auth->setClientId($pga->clientId); $ga->auth->setClientSecret($pga->clientSecret); $ga->auth->setRedirectUri($pga->page->httpUrl); $ga->setAccessToken($pga->accessToken); $ga->setAccountId($pga->accountId); $defaults = array( 'start-date' => date('Y-m-d', strtotime('-1 month')), 'end-date' => date('Y-m-d'), ); $ga->setDefaultQueryParams($defaults); $params = array( 'metrics' => 'ga:pageviews', 'dimensions' => 'ga:pagePath', 'sort' => '-ga:pageviews', 'max-results' => 11, ); $visits = $ga->query($params); $out = "<h2>Most read articles</h2><ul>"; foreach($visits['rows'] as $row) { if ($row[0] == "/") continue; // Skip the homepage, should be on top 10 always, if not, then 11 articles is shown $p = $this->pages->get($row[0]); if ( ! $p->id ) continue; // For some reason page is not found anymore... $out .= "<li><a href='$p->url'>$p->title</a></li>"; } $out .= "</ul>";
-
It ain't that hard Marty. Hit the questions and we'll help.
-
exactly. if your need is to have shared template with custom CSS, then it is small adjustment to above scenario.
- 27 replies
-
- multisite
- many pages
-
(and 2 more)
Tagged with:
-
Moving PW installation is dead simple: copy everything (also hidden files) from /cms/ to one folder up. Of course you can also go to manage your apache and change where your webroot is, but I think copying the folder is easier way to go.
-
Fredi likes when he gets special treatment like that.
-
Great stuff Adrian. Using cloud service like http://zencoder.com/en/ or http://features.encoding.com/ might be good option too.
-
since you are using api already, try this right after your save: $p->name = $p->id; $p->save();
-
I found it pretty logical (but not common). It divides two groups. Not intended to use between each element. If you want divider between each nav element, then just style it.
-
Keep in mind: If you don't enjoy or don't want to spend time to learn site building and want to focus on content, then I would suggest using some website tool like squarespace etc. or having friend or collegue who does the maintenance work. But if you do want to learn new tech, then we are here to help. PW is great tool to learn site building "the right way"
-
I would set something like this: Create template called babysite. Give it all the fields you need. Then create /templates/babysite.php It would be something like this: <?php $pathToTemplate = $config->paths->templates . "babysites/" . $page->name . "/index.php"; // If babysite index.php exists, we include it, otherwise we include default or throw an error if (file_exist($pathToTemplate)) include($pathToTemplate); else throw new WireException("TemplateFile couldn't be found"); This assumes you keep your babysites at /site/templates/babysites/babysitename/index.php That is good folder to keep babysite assets too, but of course you can get those from everywhere. You could of course take this much further. But if babysites doesn't share much together (like some basic structure), then I think this would be simplest and most straightforward way to go.
- 27 replies
-
- 1
-
-
- multisite
- many pages
-
(and 2 more)
Tagged with:
-
actually I have no clue FieldtypePoll module is about only thing I have done with Angular, and I am pretty sure it has all the worst practices..
-
any errors on js console?
-
template != template file (usually html & CSS) You need one template, call it "babysite". Then load site specific CSS when needed and in some case probably site specific HTML too. This is very straightforward and we are here to help. on mobile atm, would provide code examples otherwise.
- 27 replies
-
- 2
-
-
- multisite
- many pages
-
(and 2 more)
Tagged with:
-
There is no support for variation combinations. I would suggest keeping shirts with different colors as their own products and sizes as variations.
-
I just committed the support for variations (using repeaters): create a repeater which has title and sc_price fields add it to your product template loop your variations on product page (you can have product without variations too) Here is example code for looping the variations (or using fixed price). Repeater is called shop_product_variations: $sc = $modules->get("ShoppingCart"); if ($page->shop_product_variations->count() > 0) { $page->body .= "<p>Choose variation:</p>"; $page->body .= "<div class='variations'><form method='post' action='./'><table>"; foreach ($page->shop_product_variations as $p) { $page->body .= "<tr><td><input type='radio' value='{$p->id}' id='sc_product_id_{$p->id}' name='sc_product_id' /><label for='sc_product_id_{$p->id}'>{$p->title}</label></td><td class='price'>". $sc->renderPrice($p->sc_price) ."</td></tr>"; } $page->body .= "</table><input type='number' class='sc_qty' name='sc_qty' value='1'/> a <input type='submit' value='Add to Cart' /></form></div>"; } else { $page->body .= "<div class='price'>Price: ". $sc->renderPrice($page->sc_price) . "</div>"; $page->body .= "<form method='post' action='./'><input type='hidden' value='{$page->id}' name='sc_product_id' /><label for='sc_qty'>Qty</label><input type='number' class='sc_qty' name='sc_qty' value='1'/> <input type='submit' value='Add to Cart' /></form>"; } And example of variations on live site: http://www.martanpuoti.fi/tuotteet/mennaan-eika-meinata-t-paita-unisex/muut-tuotteet/
-
Thanks Ryan! I will investigate that route. This clarified a lot.
-
Ryan, I am building new set of modules, that will create user access management easier for clients. Current way with roles, permissions and template access is fine for most needs, but very common scenario for our clients is "I want to allow these 5 groups of users to view this branch of pages and then these 3 groups of users to edit and add those pages". I cannot open the template editing, or start talking about roles and permissions to our clients - it is way above of their needs and thinking. What they want is to go into a page and choose groops that can view and choose groups that can edit this page and below it. To solve this I thought ideal would be to introduce new "term" to PW user management: groups. Groups just collect users directly or by tieing users into groups through roles (so you can say that all users that have role "editor" or "superuser" belong to group "site editors"). This part I have already figured out and working nicely. Now I am back basicly what CustomPageRoles does: altering the current way of user access. This time I want to go deeper - I want to check user access in DB query level. I need all working right: count and pagination also. This probably means keeping own version of "pages_access" table and altering how PageFinder filters results. It would be very helpful for me, if you can describe little more how getQueryAllowedTemplates works and what it does? If I read the code correctly, it checks the allowed templates and based on that, it filters results. I think what makes it difficult for me to follow, I am not 100% sure how static properties work there . When moving from template based ua to page based, would it be enough to replace getQueryAllowedTempaltes method with page specific filtering? I would be happy to build upon the template based access, but I don't see how I can do that. I need to give client ability to give view/edit access to any group in any page, without me or them need to go editing roles, permissions or templates.
-
this doesn't redirect, if you have page in place. only when 404 occurs this module checks if redirect is required.
-
Ok... now that I see dead avatars, maybe it is time to roll back time.
-
Currently it gives me an error: Parse error: syntax error, unexpected '[' in /.../site/modules/ProcessPageTreeMigrator/ProcessPageTreeMigrator.module on line 666 And the code there is: $newArray = []; So it requires php 5.4. Just changed it to array() and now it works. Importing full data still doesn't work, this time it seems to be repeaters: FieldtypeRepeater: Created Repeater Page Parent: /processwire/repeaters/for-field-98/for-page-1067/ TemplateFile: Method RepeaterPageArray::setLanguageValue does not exist or is not callable in this context For me export & import of templates and fields is the main selling point of this module (not the data).