Leaderboard
Popular Content
Showing content with the highest reputation on 09/24/2012 in all areas
-
This module creates a page in the ProcessWire admin where you can test selectors and browse page data and properties without editing a template file or a bootstrapped script. Given selector string is used as is to find pages - only limit is added, if given. Errors are catched and displayed so anything can be tested. Pages found with a valid selector are listed (id, title) with links to the page. I was thinking this would be useful for someone new to ProcessWire, but it turns out I'm using it myself all the time. Maybe someone else finds it useful as well. Module can be downloaded here: https://github.com/n...essSelectorTest Modules directory: http://modules.processwire.com/modules/process-selector-test/ Features Edit selector string and display results (and possible errors as reported by ProcessWire) Explore properties and data of matching pages in a tree viewLanguage aware: multi-language and language-alternate fields supported Repeater fields and values Images and their variations on disk More data is loaded on-demand as the tree is traversed deeper Quick links to edit/view pages, edit templates and run new selectors (select pages with the same template or children of a page) Page statuses visualized like in default admin theme Add pagination Screenshots4 points
-
(Ah, Antti was faster, but I'm trying to explain things from another point of view I think. Here goes.) Apeisa is using "first level" of template files as controllers. By "first level" I mean the files that are named after the templates themselves. Then the controllers can specify which layout should be used, giving the possibility to construct output according to some common layouts (frontpage, threeColumns, etc). The file /markup/index.php checks whether $page->layout has been set and uses either the given layout or the default one to render the output. "layout" does not have to be a field in any template as you can set any key to a value in a Page object by saying $page->key = "value". That is equivalent to saying $page->set("key", "value"). Fields in the template assigned to this page can be used in the same way, but as I said, there does not have to be such field defined beforehand. Of course assigning values to keys that don't map to any field in a template doesn't get them saved to the database if $page->save() was called. Hope this clarifies it a bit.2 points
-
It's pretty obvious because of diogo's code comment but just in case you're wondering; he's using a so called ternary operator. Which is basically the same as this If/Else statement: if($feature->thumbnail) { $thumb = $feature->thumbnail->size(244,244)->url; }else{ $thumb = "[url to the placeholder]"; }2 points
-
<?php $features = $pages->find("template=portfolio, limit=4, sort=-date"); foreach($features as $feature) { $thumb = $feature->thumbnail ? $feature->thumbnail->size(244,244)->url : "[url to the placeholder]"; // if no thumbnail, replace by placeholder echo "<li>" . "<a href='{$feature->url}'><div id='explore_thumb'><img src='{$thumb}'></div>" . //changed from $thumb->url to only $thumb "<h3>{$feature->title}</h3>" . "<h4>{$feature->summary}</h4></a>" . "</li>"; } ?>2 points
-
I am having problems with this module. It seems to save the embed codes into the database, which is good. Bad thing is that it saves only one line there. This causes every video to be the same. It seems to fail on video_id part, since my only row in textformatter_video_embed table is this: www. <iframe width="640" height="360" src="https://www.youtube.com/embed/9StIWIg03eM?fs=1&feature=oembed" frameborder="0" allowfullscreen></iframe> 2012-09-19 10:40:44 So it saves only www. as video_id and seems to that with every video. Is this problem only on my installation or are other experiencing the same? My url in textarea is in this format: https://www.youtube.com/watch?v=9StIWIg03eM&feature=related2 points
-
TemplateBadges is now TemplateDecorator. I've pushed up a new version with some new features - it now has a configuration screen where you can configure a default icon. I've included a "blank" and a simple "page" icon which are good choices for default icons. There is also an option to display the template name when editing a page. The tab is now called "Decorations", and has an added field for directions - if you add directions, they will display near the top of the "Content" tab, when editing a Page with that Template. The Github page is open to submission of issues - post'em if you got'em. Note that this was tested with the current dev-branch of PW, and works without modifications.2 points
-
Hi, Beto. This topic has been discussed here. Also check out Ryan's Blog Profile.2 points
-
For those of us on the west side of the Atlantic; I could help to organize a meeting/conference in Cancún. I give social media and SEO courses there 5 times a year, so I know the place and I am very enthusiastic about it. Don't you like caribbean beaches?2 points
-
PageListImageLabel Marty requested and sponsored a new module little while ago. http://processwire.c...t-image-option/ I just wanted to create a separate release thread. Many thanks to Marty for sponsoring and making this possible. This just shows how great this community is. So here it is the Page List Image Label module. It enables you to add thumbnails of images from the pages in the admin page tree. Download: http://modules.processwire.com/modules/page-list-image-label/ Github: https://github.com/somatonic/PageListImageLabel A screenshot of it in production. (old version)1 point
-
Few days ago I've posted sneak preview of new admin template (it didn't have name then), so I've managed to squeeze some time to finish it and here it is... Ergo Admin Template DOWNLOAD https://github.com/nvidoni/ergo USAGE 1. Create folder named "templates-admin" under /site/ folder 2. Copy all files (including folders) into newly created folder 3. ProcessWire will load the new admin template automatically EXTRA If you would like to use custom TinyMCE theme created for this template, follow this steps: 1. Download TinyMCE Ergo theme from https://github.com/n...ni/ergo-tinymce 2. Copy "ergo" folder to /wire/modules/Inputfield/InputfieldTinyMCE/tinymce-3.4.7/themes/advanced/skins/ folder 3. Open /site/templates-admin/default.php and change in line 86 "default" to "ergo" If you find any errors please post them here so I can commit them accordingly. EDIT 1. Changes have been made according to diogo's and Soma's posts.1 point
-
One of my clients specializes in putting on conferences/summits around the world, primarily focused on architecture and sustainable design. I mentioned to them how some users here (starting with Netcarver) had expressed interest in a ProcessWire meetup or conference in the UK. This client does conferences in the UK every year and they are extremely enthusiastic about ProcessWire and interested in helping us to put on a conference by letting us collaborate with their conference and share the same venues and accommodations. This would help us benefit from their expertise in putting on conferences (which they've done for more than a decade), as well as help [significantly] on costs in reserving the venues, food, hotels. I have worked with this client since 1994 (18 years), so have a very high level of trust with them. The conference would be in August 2013 and be 1.5 days in London at a major ad agency, then we'd step on a train for an hour or so and do the rest of the conference in Cambridge at Kings College for another 1.5 days (total 3 days). This would be a small but relatively formal conference with presentations and workshops covering everything ProcessWire, design and web development. We'd cover topics at a higher level than you'd find anywhere else in the world. I don't yet have an idea on costs except to say that we'd find a way to make it accessible to as large of an audience as possible, and it would be completely non profit, food and accommodations (for those that wanted it) included. Yet, it'd still be higher class and more personal than any other webdev conference. This is about a year out, so I'm interested in finding out who'd be interested in this. Please 'like' or reply to this post if you would be interested in attending (or presenting) at this conference.1 point
-
I wonder how different people handles different "file structures" for templates. I know that you can only put php code inside a template files, and i have thought that when you have to create a lot of unique "pages" with different php code it will take time to create a template file for each page. Not only that, but eventually, if you create a lot of templates, the templates folder would get very crowded. I was looking for a better way to organize my php files and found this solution. Instead of creating a template for each unique page with custom php code, I just create a single template named "include". This template just has two fields: title and include_path. The code of this template is just: <?php include $page->include_path; ?> In the "include_path" field I set the relative path for including other php files, and this method gives me a more organized collection of php files nested in various folders. For example, for a form called "reservation", I would just create a page with the template "include", and the field "include_path" set to "./php/forms/reservation.php". An example of this file structure: site/ --templates/ -----/styles -----/scripts -----/php --------/forms --------/processes --------/catalogs --------/galleries -----head.inc -----foot.inc -----home.php -----blog-post.php -----include.php Do anyone know if there is a better way to handle php files? o anybody would share their file structure approach?1 point
-
Thanks Nik, well described. I'm on mobile, so little spare on words. Gazley: you mean on pw admin? My templates are just normal. If I have template called "news-item" I'll let it go to news-item.php. Many times actual template file is very short, sometimes only the included index.php file and chosen layout (if not default).1 point
-
Layout could be user defined field. I haven't got the need yet. Layout is more like inner template. All pages have same header and footer, these come from index.php. But then in main section of the site I usually have few different layouts, one for frontpage, two columns, three columns etc. Then if my template doesn't use default one, then I just switch it in template file: $page->layout = "wide"; That setting could easily be user defined if you want client to choose from different content layouts. As you can see, I haven't come up with good term for that inner template. Since pw uses template, I ended up calling it layout. And I set that $page->layout = "wide" in my template code.1 point
-
I think you've got a good method there, but just be mindful of security. Any time you let paths and files be specified from the admin, you've really got to trust whoever will be populating those paths/files. When it comes to template files, it's best if you keep all the shared stuff out of them and include that separately. For instance, the basic profile includes head.inc and foot.inc, which represent the markup common to all pages. But you can take that much further, delegating to separate includes for other elements when it makes sense (sidebar, navigation, etc.) I also like an approach where you setup some common features in your template that you can turn on or off with checkboxes on the page. For instance, you might have a checkbox that turns on/off the sidebar or comments, etc. And the detection and display of those things would likely be in your shared include files like head.inc or foot.inc. So when it gets down to the actual template file, it doesn't have to focus on anything other than what's completely unique to that template. Even on very large sites, its rare that you should need a lot of templates if you are using them as types and controllers rather than using them to represent minor markup changes. But there are a whole lot of approaches that you can take, and what is best for one may not be for another.1 point
-
My suggestion was simply to create a "projects" page, and have all the projects as it's children: -projects (template "projects") --projectA (template "project") --projectB (template "project") --projectC (template "project") Template "projects" doesn't need any field, or even a template file associated. It exists only for holding the children. (in the "family tab" of template editing, choose "project" as the only allowed template for children) Template "project" has the fields "title", "budget" and "description". Doesn't need a template file if you don't want them to have their own URL. (in the "family tab" check "no" for "can this template be used for new pages?") On your "construction projects" page template do something very similar to the above: <? foreach($pages->get("/projects/")->children as $project): ?> <h3>project name</h3> <p><?=$project->title ?></p> <h3>project budget</h3> <p><?=$project->budjet ?></p> <h3>project description</h3> <p><?=$project->description ?></p> <? endforeach; ?> The editor just have to create a new page under "projects" for each project. This is the most common way of doing this kind of thing on PW.1 point
-
I like Caribbean beaches This is good to think about for the future if we find we have many users near that area.1 point
-
You could certainly set your homepage template to redirect to that URL when the homepage is accessed without a language GET variable. But I think it would be much better to just assume that your 'default' language is 'it'. There is no rule that the default language has to be English or anything else. The only rule is that it just has to be named 'default' (in the admin), but it is there to represent whatever you want your default language to be. In your case, it sounds like you want your default language to be 'it' since you are wanting an access to /index.php to instead go to /index.php?language=it. So the proper way to do this is to use the default language as its intended. But if you are still wanting to do exactly what you asked, you would do this in your homepage template: if(!$input->get->language) $session->redirect($page->url . '?language=it');1 point
-
Teppo, the dev branch now now has switched from extension detection to type detection per your suggestion and code. https://github.com/ryancramerdesign/ProcessWire/blob/dev/wire/core/ImageSizer.php Thanks, Ryan1 point
-
1 point
-
Looks like I broke this a couple weeks ago, but it was an easy fix. Thanks for finding it.1 point
-
1 point
-
Hey Ryan, Works for me! Sorry to have inadvertently pushed you into doing something that you probably would have wanted to do at a more convenient time! Thanks for the speedy turnaround Cheers!1 point
-
Thanks, it was my pleasure. And a bit pain as well, but mostly pleasure.1 point
-
You should think if repeaters are the best way of achieving what you want. In this case, I suspect that it would be better to create each project as a child of a "projects" page. But I will answer your doubt anyway. Its not much different then doing the same with other kinds of fields. But, like with images, the field return a page array that you have to iterate with a foreach() Taking the example on the repeater fields docs http://processwire.c...ypes/repeaters/ (is this one that you were talking about?) foreach($page->buildings as $building) { echo "<h2>{$building->title}</h2><p>"; echo "Height: {$building->feet_high} feet, "; echo "Floors: {$building->num_floors}, "; echo "Year built: {$building->year_built} </p>"; } Notice that it's not that different from your example, and all the html is being echoed from inside the foreach. The same example can be also written with this alternative sintax, if it makes it more clear for you: <? foreach($page->buildings as $building):?> <h2><?=$building->title ?></h2> <p> Height: <?=$building->feet_high ?> feet, Floors: <?=$building->num_floors ?>, Year built: <?=$building->year_built ?> </p> <? endforeach; ?> You just have to adapt it to your html code. In your case I can imagine something like this: <? foreach($page->projects as $project): ?> <h3>project name</h3> <p><?=$project->name ?></p> <h3>project budget</h3> <p><?=$project->budjet ?></p> <h3>project description</h3> <p><?=$project->description ?></p> <? endforeach; ?>1 point
-
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.1 point
-
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.1 point
-
Nice discussion, thanks for posting guys. Our setup is pretty much similar to Ryan's (got good tips there when build it), although I have little bit of Soma's method baked in too If I take Ryan's example, then our main.php would be something like this: <html> <head> <title><?php echo $page->title; ?></title> </head> <body> <h1><?php echo $page->title; ?></h1> <?php if ($page->tpl) include("./tpl/{$page->tpl}.inc"); else include("./tpl/default.inc"); ?> </body> </html> Then I would set that $page->tpl in actual template file (like product.php, event.php etc), if I need to. Of course it would also be possible to allow client to choose tpl on certain page templates (using basic page field selection), but I haven't had the need yet. This way I can use same basic wrapper even though markup inside body tags would be totally different. This also allows to have $page->tpl as selection for page editors if that is needed (not yet the case). Most of the time it seems that default.inc works 90% of the time.1 point
-
Hi Stewrat and welcome to the forums! TinyMCE uses style="text-align: right" to set alignments. That being said this worked for me: My addition on bold. But beware - if this is something that client will use, it will allow all kind of stuff (colors, font-sizes etc) introduced to your content. I am not sure if you can say something like [style=text-align] (did try that, did allow everything on style) that would allow only the alignment?1 point