-
Posts
4,632 -
Joined
-
Last visited
-
Days Won
55
Everything posted by apeisa
-
Out of interest, who's using Less/Sass vs plain old CSS
apeisa replied to onjegolders's topic in Dev Talk
For me CSS is the "fun, easy and quick" part. I don't feel like I am wasting my time there and I feel like I can make much bigger gains by improving on other aspects of my work. There are so few browser quirks today and so many well supported new stuff on CSS that I find it almost relaxing. But I don't use reset.css or ie specific stylesheets either and I have pretty much dropped using browser prefixes... I don't organize my CSS much and I enjoy "clever chaos" on that stuff. Developer tools give me exact line number for the selector and that's it. I'm kind of oldschooler here Of course if I would be doing more experiments and design on css or maintain large (= really huge) sites etc then I think it might be much more valuable for me. I am pretty sure that in some personal project I will try some css pre-processor, and if I find it huge improvement (like 5 times cleaner and faster than pure css) then I might start thinking how to make it part our workflow at Avoine. To be honest, I don't see that happening anywhere near though. -
Repeater does make nice carousels.
-
Running latest and greatest version of PW?
-
Do database repair (can be done from phpmyadmin), also try saving your home page and also all direct children.
-
Just installed this one and it works like a charm! Really nice and very polished work. Very nice that it is already multilang friendly! Few ideas for further development: There are quite a lot stuff on screen. It might be nicer UI if you would use tabs instead of folding for main categories (audience, content, traffic sources) Showing current month is what I usually want, but it would be nice to have ability to choose date range Link to Google Analytics when you want to dive deeper into the analytics Consider using strftime instead of date - that would allow local month names etc for other languages than English. Not necessary though, since one could always define numeric only dates (like 9.8.2012) http://www.php.net/manual/en/function.strftime.ph
-
Config property to check for if on admin or frontend
apeisa replied to Soma's topic in Wishlist & Roadmap
ready() -
Whoa! Looks amazing and very useful module. Will definitely try this soon!
-
Adam: nothing else I guess. But if you do have written bad code in your templates, then of course one could use it against your site. Not sure why you want to do this? Allow people to contribute, to get feedback or as an example? If for example, one thing you could consider is releasing it as a site profile with dummy content or something like that.
-
This got me thinking that maybe having cropimages and image-effects as fieldtypes is not best solution. What if I want to crop and also add some effects?
-
How can I specify default value for certain input field?
apeisa replied to PawelGIX's topic in General Support
It is definitely something that you think you do need (of course you need default values), but in real life I haven't got the need even once (only default date). -
Confirmed here too. Glad that it isn't anything worse: it is possible to drag after instert to correct position.
-
Hi and welcome to the forums! That comes from the classname. Camelcases are preferred there and modules directory will use first word as a category. I would myself try to build the API methods first and after that is working start to build the admin usage. You also might find some help from my thumbnails modules: https://github.com/apeisa/Thumbnails Interesting module and I hope to help you more soon (pretty busy today). That is not the simplest one for first module, but the need is a good motivator I'm sure you find good help from here. Ryan is on holidays this week, but there are many who can help you out. Also, if you can point out more exact questions it will help us to help you.
-
A different way of using templates / delegate approach
apeisa replied to Soma's topic in API & Templates
I am not sure but Adam's new module might do just that: http://processwire.com/talk/topic/1589-render-%E2%80%93-views-for-processwire/page__pid__14536#entry14536 I agree with Soma here: that is nowhere near dirty hack. Because of you are already editing template/markup files then having that setting inside template files instead of admin ui is much better in my opinion. -
A different way of using templates / delegate approach
apeisa replied to Soma's topic in API & Templates
Robert, if I understood you correctly, that is exactly what my method does also. It doesn't do it automatically, since I want most of my templates to use same view (default.php), but it is possible to set any view just by saying: $page->layout = "post"; I am pretty sure that similar thing is possible on Soma's approach also. No dirty hacks needed to get such an output. -
Great Adam! I think maybe more detailed example would help a little, I didn't figure out how it fully work.
-
A different way of using templates / delegate approach
apeisa replied to Soma's topic in API & Templates
Sure, actually will add one of these into first example. But here are both: Carousel.php <?php /* Generates the markup for the frontpage carousel */ if (count($carouselPages) < 1) return; echo "<div id='carousel'><ul class='rslides'>"; foreach($carouselPages as $key => $p) { echo "<li class='c-item c-item-$key'>"; echo "<img src='".$p->image->getThumb('carousel') ."' alt='' />"; echo "<p>$p->summary</p>"; echo "<a class='button' href='{$p->link->url}'>$p->headline</a>"; echo "</li>"; } echo "</ul></div>"; items.php <?php if (isset($title)) echo "<h2 class='items-title'>$title</h2>"; echo "<div class='items'>"; foreach($items as $key => $p) { $key++; if ($key > 3) { $key = 1; echo "<hr class='padding' />"; } echo "<div class='col{$key}of3 item'>"; echo "<img src='". $p->featured_image->getThumb('thumbnail') ."' alt='' />"; echo "<h2 class='title'><a href='$p->url'>$p->title</a></h2>"; echo "</div>"; } echo "</div>"; And as additional bonus, items-with-description.php (it includes the items.php from above): <?php if (count($items) < 1) return; $items = $items->slice(0,3); include('./items.php'); echo "<div class='col1-2of3'><p>$description</p></div>"; echo "<div class='col3of3'><a class='button block' href='$url'>$linkTitle</a></div>"; Uh, just realized that my site has evolved a little. Those in my example actually use "items-with-description.php" instead of just "items.php". There is also my "default-masthead.php": <?php $img = $image->width(304); ?> <div class='col1-2of3'> <h1><?= $title ?></h1> <p class='summary'><?= $summary ?></p> </div> <div class='col3of3'> <img src='<?= $img->url ?>' alt='' /> </div> -
wire("config")->urls->admin in autoload module init() not available?
apeisa replied to Soma's topic in General Support
In modules you always have to use either wire('config') or $this->config -
A different way of using templates / delegate approach
apeisa replied to Soma's topic in API & Templates
It is pretty simple and straightforward. It loads the file and then you can set variables for it. Then you can render the output (directly echo or save to a variable which get's echoed later on). It doesn't differ that much from having functions that return the output, but I think having them as separate files is much cleaner. And no need to passing variables as function parameters is nice also. It is pretty close to plain simple includes, but it allows to save the output to a variable instead of directly outputting it. That is pretty much all it does (same as this: http://php.net/manual/en/function.include.php#example-140). This difference allows you to keep your actual template file purely as a controller if you want to (like in my example there is always last line include("./markup/index.php"); which starts the output). -
A different way of using templates / delegate approach
apeisa replied to Soma's topic in API & Templates
After Ryan's latest incarnation of Blog Profile I wanted to see if I could learn something from there to my own workflow. It turned out very nicely and this seems like a perfect template approach for me. Wanted to share it with you guys. Folder structure under templates folder: templates/markup/ templates/markup/helpers/ templates/markup/layouts/ templates/scripts/ templates/styles/ And it all begins from here: templates/markup/index.php -this is the "complete" html file, it has doctype, head and starting and ending body. There is very little "logic" here, it's more like a container. There is one very important code snippet there though: <?php if ($page->layout) { include("./markup/layouts/{$page->layout}.php"); } else { include("./markup/layouts/default.php"); } ?> Code above goes between header and footer of your site, that will be the main content. I call it layout, but the better name would be "content layout" or "inner layout" or something like that. Then the templates/markup/layouts/ folder will keep at least default.php file, but probably few others, like "threeColumns.php", "frontpage.php", "gallery.php" etc.. you got the idea. Each of the actual pw template files are then purely "controllers" - no actual markup generated there. All markup are done in files inside templates/markup/ folder and it's subfolders. This is how template file templates/home.php on one site I am building right now looks like: <?php // Carousel items $t = new TemplateFile(wire('config')->paths->templates . 'markup/helpers/carousel.php'); $t->set('carouselPages', $page->carousel); $page->masthead = $t->render(); // Tour themes $t = new TemplateFile(wire('config')->paths->templates . 'markup/helpers/items.php'); $t->set('title', "Get inspired from our <strong>tour themes</strong>"); $t->set('items', $page->featured_themes); $t->set('description', $page->themes_description); $t->set('url', $config->urls->root . "themes/"); $t->set('linkTitle', "All themes"); $page->main .= $t->render(); // National parks $t = new TemplateFile(wire('config')->paths->templates . 'markup/helpers/items.php'); $t->set('title', "Seven beautiful <strong>national parks</strong>"); $t->set('items', $page->featured_parks); $t->set('description', $page->parks_description); $t->set('url', $config->urls->root . "national-parks/"); $t->set('linkTitle', "All national parks"); $page->main .= $t->render(); $page->layout = "frontpage"; include("./markup/index.php"); This uses few "helper" markup files from templates/markup/helpers/ folder (namely carousel.php and items.php). Here is the carousel.php for your reference: <?php /* Generates the markup for the frontpage carousel */ if (count($carouselPages) < 1) return; $styles = ''; echo "<div id='carousel'><ul class='rslides'>"; foreach($carouselPages as $key => $p) { echo "<li class='c-item c-item-$key'>"; echo "<img src='".$p->image->getThumb('carousel') ."' alt='' />"; echo "<p>$p->summary</p>"; echo "<a class='button' href='{$p->link->url}'>$p->headline</a>"; echo "</li>"; } echo "</ul></div>"; Then populates the $page->masthead and $page->main properties and then set's the inner layout to "frontpage". That templates/markup/layouts/frontpage.php file is very simple on this site, but could be much more complicated if needed: <div id="masthead"> <?= $page->masthead; ?> </div> <div id="main" class="wrap"> <?= $page->main; ?> </div> Frontpage is rather unique and I could have done all the markup on the frontpage.php file also. But I do want to re-use those "carousel" and "items" components on other places as well. But if I do have totally unique stuff, where I do want to get "quick and dirty" this approach allows it. Then my template file would be something like this: $page->layout = "campaign2012"; include("./markup/index.php"); And then all the markup would be in that templates/markup/layouts/campaign2012.php Blog profile really gave me a good ideas (cleaner folder structure etc) and using TemplateFile class adds nice possibilities. This is of course just a one way to manage your templates, but hopefully someone of you finds this helpful when thinking about how you like to structure this stuff. PS: If you are just getting started with PW, then I recommend using the head and foot includes method from demo install. There is nothing wrong with that method and only more complicated sites starts to benefit from these methods introduces in this topic.- 83 replies
-
- 17
-
-
Great news! Does it create folder when first image is added or when page with file field is created?
-
Soma you cheating on me? My fingers hurt...
-
Soma: using php cache would be pretty much identical in speed, no difference. Implementation is much cleaner though with JSONP. Ryan: you can be pretty strict - If I remember correctly jquery uses only numbers, but I think it would be good to use same sanitizing than pw pagenames have. Actually you could even hardcode it, but that would make it harder to use using jQuery's callback (since it always adds random stuff there). http://www.michaelhamrah.com/blog/2010/02/using-flickr-and-jquery-to-learn-jsonp/
-
Getting current template name - Adminbar bug?
apeisa replied to thetuningspoon's topic in General Support
Is that somehow blocking the usual class or do you get both? I don't think it should "block". -
What you are describing is called JSONP (JSON with Padding). So the original data is valid, but not usable from cross domain. You can add own "cache" for it also (get the data through local php script) - but of course would be much more straightforward if JSONP would be available also. PS: I love the modules directory and modules manager! You rock fellas!
-
Just edit the name of your subpage to match the subdomain? If that is not possible in your case, then you need another solution. Maybe fork the module for your needs?