Jump to content

apeisa

Moderators
  • Posts

    4,632
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by apeisa

  1. Ryan, any news regarding this? I am thinking about my discussion module and one upcoming project where I probably will use that (of course, more polish and tweaks will come). But there are about 50 000 posts already on old forum, that probably will be converted, so that folder limit would be real issue here. Although in Discussion module it would be fine to adjust the module to remove the folder right after saving, but of course nicer and more native solution to this problem would be welcome. There is another simple way to do "folder folding": http://superuser.com/a/66341
  2. Haven't thought about that use case at all, to be honest. I think that best way to support that would be offering "real" image cropping tool, that creates copies of original image, not just reference.
  3. This should do it (cleaned from other module, so not sure if this works without fixing, but idea should be pretty clear): <?php class Elections extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Elections', 'version' => 101, 'summary' => 'Simple module to demonstrate how to automatically create subpages.', 'singular' => true, 'autoload' => true, ); } public function init() { // add a hook after the $pages->save $this->pages->addHookAfter('save', $this, 'afterPageSave'); } public function afterPageSave($event) { $page = $event->arguments[0]; // We want to create subpage only when using if ($page->template == 'election' && $page->numChildren == 0) { $p = new Page(); $p->template = $this->templates->get("candidates"); $p->parent = $page; $p->title = "Candidates"; $p->sortfield = wire('fields')->get('v_candidate_number'); $p->save(); $p2 = new Page(); $p2->template = $this->templates->get("votes"); $p2->parent = $page; $p2->title = "Votes"; $p2->save(); $this->message("New election created."); } } }
  4. I have few modules that does that. Nothing generic, but I'll post you examples when I'm on computer again (tomorrow). Unless someone is faster of course
  5. Soma: sounds great. Make sure you support link abstract module links (those should be easier for you though).
  6. Soma & porl: what would be best way to handle this in your opinion? I can think few quite a different options how this can be fixed.
  7. apeisa

    page slots

    I think it might be little different what you are after. How concrete5 and apostrophe does basic text & image placement is pretty nice and much better than TinyMCE or any other "big content area" method. But if you go beyond "text & image placement" then the method what ProcessWire, Drupal and Expression Engine does is much better. With "drop content blocks here and there" method you do end up with same end result than always using just single TinyMCE field: huge bunch of content without any (or very little) metadata baked into it. If you use more structural cms (and use it "right") then you end up "slicing" your content into smaller pieces. This allows you to build much better websites in the long run. You can easily build tiny applications around your content (see Ryan's Skyscrapers site: http://processwire.com/skyscrapers/ - which would be pretty much impossible to build, if your content is build with just huge text areas) . Other area where easy "text and image placement" falls short is when you do want to use your data in different context. The way you positioned your images inside your text elements probably doesn't work in your mobile site, or in that nice flash application that uses same data. Of course there are times when we (or our clients) do need to mix some images inside their body copy - and the current way in PW is to use TinyMCE or Diogo's image tags module: http://processwire.c...ags/#entry10663 (or something similar).
  8. There is unnecessary ) on Ryan's example after first children. This line: foreach($pages->get("/students/")->children) as $gender) { should be: foreach($pages->get("/students/")->children as $gender) {
  9. You have pretty extreme options soma I'd say few times in a week and I most often find what I was looking for very fast. Great resource!
  10. There are other than a-z chars supported, but not sure how. It might be on browser level. If I go to http://fi.wikipedia.org/wiki/ääkköset it all works and looks nice... but when I copy & paste the url from address bar (chrome), I get this: http://fi.wikipedia....g/wiki/Ääkköset EDIT: I mean I get this: http://fi.wikipedia.org/wiki/%C3%84%C3%A4kk%C3%B6set
  11. I am planning to make all render methods (the ones that output markup) hookable and also configurable. Although other way to look at it is that these modules should give you all the "low level" methods that make it simple to build your own cart. So current method here is to render the cart by yourself all together (in your template for example). So instead of this: <?= $modules->get("ShoppingCart")->renderCart() ?> You would do something like this: $cart = $modules->get("ShoppingCart"); $items = $cart->getCurrentCart(); foreach ($items as $item) { // get product price from actual product page $product = $pages->get($item->product_id); $total_price = $item->qty * $product->sc_price; $out .= "<td>{$product->title}</td>"; $out .= "<td><input data-price='" . $product->sc_price . "' name='items[{$product->id}]' type='number' size='2' value='" . (int) $item->qty . "'/></td>"; $out .= "<td>" . $cart->renderPrice($total_price) . "</td>"; $out .= "<td><a class='remove' href='./?sc_remove=" . $product->id . "'>remove</a></td>"; } echo $out; Well, look into renderCart() method in ShoppingCart module, it should give you best picture what to do there. But $items has all your items (page id and title), just iterate over them.
  12. I use that kind of stuff in every project. Here is one of my "MarkupRenderHelper" modules (stripped some code to make it easier to follow - might throw few errors because of that, but should give the idea): <?php class MarkupRenderHelper extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Render Helper', 'version' => 100, 'summary' => 'Simple module that adds few methods to Pagearray and Page object. -Antti', 'singular' => true, 'autoload' => true ); } public function init() { $this->addHook('PageArray::renderArticleList', $this, 'renderArticleList'); $this->addHook('Page::renderListItem', $this, 'renderListItem'); $this->addHook('Page::renderTags', $this, 'renderTags'); $this->addHook('Page::renderMeta', $this, 'renderMeta'); $this->addHook('Page::firstImage', $this, 'firstImage'); } public function renderArticleList($event) { $articles = $event->data['object']; $out = "<ul class='acticles-list'>"; foreach($articles as $p) { $out .= $p->renderListItem(); } $out .= "</ul>"; $event->return = $out; } public function renderListItem($event) { $p = $event->data['object']; $parent = $p->parent(); $out = ""; $img = $p->firstImage(); if ($p->author) $author = $p->author . ","; $out .= "<li class='$parent->name'>"; if ($img) { $img = $img->width(130); $out .= "<img src='$img->url' width='$img->width' height='$img->height' alt='$img->description' />"; } $out .= "<div class='text-holder'>"; $out .= $p->renderMeta(); $out .= "<h2><a href='$p->url'>$p->title</a></h2>"; $out .= "<p>$p->summary</p>"; $out .= "</div>"; $out .= "</li>"; $event->return = $out; } public function renderMeta($event) { $p = $event->data['object']; $parent = $p->parent(); $author = ($p->author) ? $p->author . "," : ""; $out = "<span class='meta'><a href='$parent->url'>$parent->title</a> $author $p->publish_date </span>"; $event->return = $out; } public function renderTags($event) { $p = $event->data['object']; $out = ''; foreach($p->tags as $tag) { $out .= "<a href='$tag->url'>$tag->title</a>"; if ($tag !== $p->tags->last()) $out .= ", "; } $event->return = $out; } public function firstImage($event) { $p = $event->data['object']; if (count($p->images) > 0 ) { $img = $p->images->first(); } else { $img = false; } $event->return = $img; } } Sometimes I add "widgets" for $pages object too. Then I can just do <?= $pages->renderInfobox() ?> or something like that.
  13. This might be what you are looking for Marty: http://processwire.com/talk/topic/263-creating-archives-for-newsblogs-sections/ Pete: no need to loop all the articles just to get all the years, you just need to know the first year there has been article published.
  14. If I understood correctly this is a scenario where "repeater A" includes "repeater A"? I'm not in a position to test, but does it work if I have two different repeaters and other one is part of other? Like "repeater A" has "repeater B"..
  15. I am - and I think others too - very impressed about this module. The issues you are solving are one of the hardest there is and go pretty deeply into the PW. So great respect from here and warm welcome to the community!
  16. You use $image->url where you should use $thumb->url
  17. Looks great, can't wait for the release!
  18. Definitely something strange going on. I get these results: without ->get("/"): res: 1|3|6|8|9| ... |1018|1029|1031|1032|1033|1034|1035|1036|1037|1038|1051|1053|1054|1055|1056|1059|1064|1065|1066|1067|1068 with ->get("/"): res: 3|6|8|9| ... |1018|1029|1031|1051|1053|1054|1055|1056|1064|1065|1066|1067|1068 It seems that those pages missing with ->get("/") are all direct children for homepage... At least on my test site.
  19. Soma, I don't spot any difference between those two.
  20. https://github.com/apeisa/Shop-for-ProcessWire Invoice or Suomen Verkkomaksut, but I am planning to build the paypal this summer. Super busy at work currently, cannot promise anything extra for this spring...
  21. Well.. after template specific field settings the need for new fields have been much less and it is easier to use more generic field names. My usual projects do have all or some of these for example: image images file files summary body date datetime tags (page field) I also have some common template names used in many projects: basic-page home members-home events event news news-item I try to use what is given on demo template. Also, trying to keep all the field and template names In English. Nothing too special here, interested to hear about others.
  22. I had need for multiple feeds and it seemed to be pretty straightforward implementation. Only few modifications to load method: public function load($url) { $this->items = new WireArray(); if (is_array($url)) { $items = array(); foreach ($url as $feed) { $xmlData = $this->loadXmlData($feed); $xml = simplexml_load_string($xmlData); $items = array_merge($items, $xml->xpath('/rss//item')); } $rss = simplexml_load_string($xmlData); } else { $xmlData = $this->loadXmlData($url); $rss = simplexml_load_string($xmlData); } if(!$rss) { $msg = "Unable to load RSS feed at " . htmlentities($url) . ": \n"; foreach(libxml_get_errors() as $error) $msg .= $error . " \n"; $this->error($msg); return $this; } $this->channel['title'] = $this->cleanText((string) $rss->channel->title); $this->channel['description'] = $this->cleanText((string) $rss->channel->description); $this->channel['link'] = $this->cleanText((string) $rss->channel->link); $this->channel['created'] = strtotime((string) $rss->channel->pubDate); $this->channel['pubDate'] = date($this->options['dateFormat'], $this->channel['created']); $n = 0; // If we already have $items set, it means we are dealing with multiple sources. Let's sort them if(isset($items)) { usort($items, function ($x, $y) { return strtotime($y->pubDate) - strtotime($x->pubDate); }); } else { $items = $rss->channel->item; } foreach($items as $item) { $a = new MarkupLoadRSSItem(); foreach($item as $key => $value) { $value = (string) $value; if($key == 'pubDate') { $value = strtotime($value); $a->set('created', $value); $value = date($this->options['dateFormat'], $value); } else { $value = $this->cleanText($value); } $a->set($key, $value); } $this->items->add($a); if(++$n >= $this->options['limit']) break; } return $this; } What it does it sniffs if $url is array, then loads/caches all those and merge their rss-items to $items array. Then later on that $items is sorted by pubDate. So this is fully backwards compatible => just give it an array instead of single url if you need to parse multiple feeds. If you guys can test it works for you too then maybe Ryan you can put this on your version. I can do pull request if you want to (although it seems that new and fancy GitHub for windows does mess up line endings..).
  23. Ryan: just noticed that I have totally missed to to thank you about this. I think pw currently has pretty great middle ground on this area (visibility-toggle, published-toggle, locked-toggle). One great idea that our marketing person said while updating our new site: it would be great to have simple "published" toggle on files/images too. What to do you guys think?
  24. Nico - yes, it is working totally fine on www.martanpuoti.fi - and I will of course help and fix bugs if those occur.
  25. apeisa

    Book Recommendations

    Everything goes.
×
×
  • Create New...