Leaderboard
Popular Content
Showing content with the highest reputation on 07/09/2013 in all areas
-
ProcessWire Site Profile Using Zurb Foundation 4 This is a drop-in replacement for the default ProcessWire site profile. See the live demo at: http://processwire.com/foundation/ It is mobile-first and fully responsive, capturing all the benefits of Zurb Foundation 4. Ready to be expanded upon with built-in support for deeper levels of navigation nesting in the sidebar. Pagination ready with Foundation-specific pagination output, when/if you want it. Improved search engine, relative to the basic profile. Library of Foundation-specific markup generation functions included, primary for generation of navigation (in _nav.php). Uses ProcessWire 2.3+ prepend/append template file settings making it easy to work with. It is largely stock Foundation 4 in terms of look and feel, with a few tweaks. To Install Download this profile from GitHub or mods.pw/4u. Start with a copy of ProcessWire 2.3 or newer, and its default site profile. If starting with an uninstalled copy of ProcessWire Replace the /site-default/templates/ directory with the templates directory from this profile. Replace the /site-default/config.php file with the config.php file from this profile. Run the ProcessWire installer. If starting with an already-installed copy of ProcessWire Replace the /site/templates/ directory with the templates directory from this profile. Add the following two lines to your /site/config.php file: $config->prependTemplateFile = '_init.php'; $config->appendTemplateFile = '_main.php'; Desktop Screenshot Mobile Screenshot16 points
-
Hi Hieu Do, What you're worried about is one of the biggest strenght of Pw. Having each field in a separate table does scale very well - mySQL is very fast when Joining optimized tables, like Pw generates them. Plus you have the advantage that each field can store as much metadata as needed with different table structures. Also in Pw you can label your fields different in each template context, this is supporting you to reuse existing fields. For example: In your 'member' template, just give your title field the label 'Forename + Lastname' My suggestion is: Give Pw a try, it's faster than every CMS/CMF I used before. Additionally there is the template cache, markup cache and a module from ryan called ProCache which completely bypasses MySQL + PHP serving you html pages That's the default behaviour. Pw only joins and loads fields you access, unless defined as autoload. Not quite sure what you mean here. You can specify in which fields you want to search your keywords4 points
-
Setting the password or any value directly through API won't give you any validations. This is a functionality the inputfield is usually doing and processed in a certain way (input). If used on non interactive level the API doesn't restrict you from doing things you can't do or aren't allowed in the admin. So you ultimately you have to take care of those thing when using the API directly. So while this works: $u = new User(); $u->name = "test"; $u->of(false); $u->pass = "1234"; $u->save(); "1234" isn't a valid password if PW's password inputfield would validate it, but it's correctly saved and works. Just not recommended to code public sign up form like this. So you have to take care and add some checks to make sure its min-max length is ok and also that there's some at least 1 number and letter. If you're doing it manually and want to use the validation of the password field in PW you could use InputfieldPassword. // "_pass" = the confirm password / actually two inputs $p = new WireInputData(array("pass" => "1234", "_pass" => "1234")); $inputfield_pass = $modules->get("InputfieldPassword"); // load the inputfield module $inputfield_pass->attr("name","pass"); // set the name $inputfield_pass->processInput($p); // process and validate the field // if any errors found if($inputfield_pass->getErrors()){ print_r($inputfield_pass->getErrors(true)); } // or if coming from a form (POST) with the field names already "pass" and "_pass" $inputfield_pass = $modules->get("InputfieldPassword"); $inputfield_pass->attr("name","pass"); $inputfield_pass->processInput($input->post); // process and validate the field // if any errors found if($inputfield_pass->getErrors()){ ... } After all if you're setting a Password directly manually with the API you don't need validation, you are directly responsible to make the password strong.3 points
-
2 points
-
I think this is a very good point - the thing is, different sections of your site will use different fields, so why would you want to pull in every field for pages that don't need them? You have to bear in mind that it's perfectly acceptable to have a template with just a Title field in ProcessWire (there are many practical uses) so why call in a body, summary or image field if there isn't any body, summary or image content? The whole system is designed to only access the data necessary for the page you're viewing. It's also worth noting that if you are using it for a site with hundreds of thousands of pages, there are a few caching options like MarkupCache or ProCache - the latter of which will make your site lightning fast as essentially it serves a static version of a page and bypasses PHP and mySQL completely Of course there are situations where you might have to think about the best caching methods for your particular project, but if you ask around on the forums people will point you in the right direction.2 points
-
I just posted version 2 of this profile, which makes typographic tweaks to several styles. It also adds support for photo captions, seen on the typography tests page. Also, there is now a demo site of this profile. I'm okay with only supporting IE9 and newer for the desktop view. IE8 and lower can have the compatibility mobile view. It's not like IE8 and older are blocked. They just simply get a view that works consistently in older browsers (which is basically the mobile view). I think this is smart, and better than trying to make old browsers display like new browsers. Supporting old versions of IE always means extra bulk and shenanigans in the code. The less legacy-IE monkey business, the better, IMO. But if you are building a complex desktop grid for an audience using old IE versions (like inside a government office that has standardized on IE7 or something) then Foundation is probably not the right framework for that. Here's what this profile looks like in IE8 if you are interested. The rule is that you have to start and end an attribute with the same style quote. Otherwise, they are interchangeable. I prefer to use single quotes myself. But if I'm copying/pasting something, I'm not going to bother going and changing double quotes to single quotes either. But ultimately the biggest reason is what Teppo highlighted: what makes the most sense in the context where they are used.2 points
-
I've changed the tutorial, adding that line. Joss was creating that wiki page, but he's been a bit scarce lately. @NoDice try making that change and report back if it works or not, please. It will be very helpful to get some feedback on that tutorial.2 points
-
That must be an error in the tutorial, since that variable appears only in that line. I looked on google for this code, and it appears to be from here http://processwire.com/talk/topic/2787-custom-menu-not-related-to-page-tree/, and the missing line would be this one: $has_children = count($child->children('include=all')) ? true : false;2 points
-
Oh ryan, I need this today and here it is Your timing is impeccable as ever! Excellent work once again.2 points
-
Greetings, Very interesting. I have been on the fence regarding CSS/JS frameworks for some time (experimenting but never full adopting them), but Foundation has been the one I like the best. I just have not felt sufficiently motivated to stop using my own code. And yet, I understand that it might be best to just start using a framework. With your new profile, it might make the jump even easier! I look forward to giving this a try, and I will report back on my experiences. Ryan -- THANK YOU so much for all your tremendous work, creativity, and endless generosity. Thanks, Matthew2 points
-
1 point
-
You can use scripts in commandline mode or in HTTP environment that include the pw index.php like this for example: // the absolute path or relative path to processwires index.php $PATH2PWindex = dirname(__FILE__).'/index.php'; // $username and $pass to a superuser $PWuser = ''; $PWpass = ''; // ... require_once($PATH2PWindex); wire('session')->login($PWuser,$PWpass); if(!wire('user')->active || !wire('user')->hasRole('superuser')) { echo "\n\nERROR: Incorrect UserLogin!\n\nScript stop now!\n"; exit(1); } after that you are logged in as superuser and can do all API stuff you like. I use this above as external CLI-Script and ask for credentials in shell window. You have to access the API via wire('pages'), wire('session'), etc instead of $pages or $session. http://processwire.com/api/include/1 point
-
One of the reasons for table per field design is definitely performance.1 point
-
That awkward moment when people suddenly start discussing things that you don't understand!!!1 point
-
I would try to work as much with what PW gives you and adapt the CSS, I think there's even an responsive theme in Formbuilder... but could be wrong. If you really need to adapt the HTML markup and CSS classes used by the InputfieldWrapper you can. As in this thread already mentioned: from the InputfieldWrapper.php core class /** * Markup used during the render() method - customize with InputfieldWrapper::setMarkup($array) * */ static protected $defaultMarkup = array( 'list' => "\n<ul {attrs}>\n{out}\n</ul>\n", 'item' => "\n\t<li {attrs}>\n{out}\n\t</li>", 'item_label' => "\n\t\t<label class='ui-widget-header' for='{for}'>{out}</label>", 'item_content' => "\n\t\t<div class='ui-widget-content'>\n{out}\n\t\t</div>", 'item_error' => "\n<p><span class='ui-state-error'>{out}</span></p>", 'item_description' => "\n<p class='description'>{out}</p>", 'item_head' => "\n<h2>{out}</h2>", 'item_notes' => "\n<p class='notes'>{out}</p>", ); Using the form inputfield object you could simply $form->setMarkup(array('list' => "<div {attrs}>{out}</div>")); The same exists for the classes used. But at the end I don't know if messing with it helps. Rendering form fields: As I said earlier, it's always possible to render a certain field explicit. echo $form->get("name")->render(); You could even use the form building method in this thread starting post and render fields where you like. There'll be still markup being outputed depending on the inputfieldtype, but maybe allows for more flexibility. $showform = true; $form = $modules->get("InputfieldForm"); $field = $modules->get("InputfieldEmail"); $field->attr("name", "email"); $field->label = "Email"; $form->append($field); if($input->post->submit) $form->processInput($input->post); if($form->getErrors()) { $showform = true; } else { $showform = false; // form valid, do something } if($showform) { echo "<form action='#' method='post'>"; echo "<div class='row'>" . $form->get('email')->render() . "<div>"; ... } Anything is possible, just use what you need. Think it's almost same as you would work with fields or pages.1 point
-
Thanks team - amazingly quick with the solution - that did the trick (used the new TUTtopnav.inc code from the tutorial page)! Will report back after finishing the whole thing and let you know if I run into something else. About to have dinner with some friends here in the Stockholm Archipelago, so won't be until tomorrow. //ND1 point
-
I always liked Foundation 3, but it just seemed slower (on my computer) than other frameworks. Foundation 4 doesn't seem slow at all anymore. I was initially confused by the syntax with class names like "small-4 columns" and "large-8 columns", etc. But it's actually very simple: if you want a div to have 4 columns at small (mobile) and at large (desktop) then use "small-4 columns" ...Foundation is literally mobile-first, so the "small" settings inherit through to the large settings, unless you override them. But if you want it to only have those 4 columns on at large (desktop), and 1-column stacked on mobile, then use "large-4 columns" ... which would be like the behavior of Foundation 3. If you want to define different column amounts for small and large, like say 2 columns at small (mobile) and 4 columns at large (desktop) then specify both in the class, like "small-2 large-4 columns". I never got far enough in Foundation 3 to say for sure, but I don't think it had that distinction...I think it just stacked everything at small.1 point
-
Hi Hieu, first of all welcome to PW! When i saw all the tables created from PW i was afraid too, but there are some functionalities that maybe can help: 1) You can set some fields that load only when you access them. 2) You can set "$config->dbCache = true" for caching the queries. 3) I think the search is the major problem concerning the memory consumption because by default the PW need to search in every field and so in every DB table. But i made a module that store all the keywords extracted from those fields in only one, doing so PW search in only ONE table without any JOIN. 4) There is also the cache of the entire page. Look at this module and here I must say that currently i don't had the chance to do a site with a million records, it would be interesting if we can do a test with tons of pages ! USSliberty1 point
-
The user credencials are spread on the db, for instance, the passwords are on the field_pass table, but the permissions are on the field_permissions table. Best way would be to have a PHP script to restore the accounts. Use this method ti build the script http://processwire.com/talk/topic/130-lost-password/?p=931 edit: be careful with where you keep the script, of course, since it will contain all the passwords1 point
-
@videokid, take a look at _main.php: <?php if($page->summary) echo "<meta name='description' content='$page->summary' />"; ?> <link rel="stylesheet" href="<?=$config->urls->templates?>foundation/css/foundation.css" /> String interpolation only works when variable is in double quotes and in those cases it's just easier (and source-wise more readable) when single quotes are used instead of escaped double quotes (\"). On the other hand, elsewhere it just makes sense to use double quotes1 point
-
This error would indicate there's a syntax error missing closures or something. But since there's no such fault in PW and in ProcessPageSearch module, looks a bit like you're files weren't uploaded completely or something got corrupt.1 point
-
Superb work. However I would like to let you know that foundation 4 is only supporting IE9+. It is sad because it seems more flexible than bootstrap(which is IE7+). If you can deal with this, then give it a try!1 point
-
maybe a custom coded form that could use formbuilder to process the submissions? i suppose you could just copy the code that formbuilder generates and put in your classes... another useful thing you can do with formbuilder is create a jquery-ui.js and main.js files, so you can use different js libraries (validators, custom time pickers etc.)..1 point
-
Thanks so much Ryan, I'm just getting started with PW and am totally new here. Being a Wordpress developer for at least 5 years, now I realize that I've been stucked too long in its fixed structure. PW opens my eyes and gives me more innovation. This new site profile is awesome and totally convince me to stay with PW. Again, thanks so much Ryan. You're a super man.1 point
-
Ryan, Thank you for sharing this — I just spent an hour dissecting, and learned some new tricks. Much appreciated.1 point
-
Thanks Ryan! This is really great and a huge timesaver. Also learning new stuff about 2.3 this way is ideal.1 point
-
1 point
-
Video blocked in the very homeland of Led Zeppelin! Ha ha. Good tune though. I used to crank that in my tiny little car. I also really like the keyboard solo in "All of My Love". And "Big Log" is great for relaxing. <-- hmm ha ha Thread contributions: Uptempo Uptempo Slow https://www.youtube.com/watch?v=AA1eeKAXF5c Slow https://www.youtube.com/watch?v=Ify-buS9JUU Fashionable How I feel when I get to reuse a PHP function I wrote for a previous site1 point
-
Wow! Very much appreciated, thanks Ryan! I've been stuck on Foundation 3 since I've never really grasped the "new" Foundation 4 syntax. I'll study this profile to see if I can get it1 point
-
1 point
-
1 point
-
I would go ahead and create your new translation and post it as a follow-up reply to the existing one. If there's no response from the original authors (like pulling updates into the existing one) then we could just make your new version the current version linked by the directory. We don't usually break the API with new releases, though did have to in the 2.0 to 2.1 release. It may also happen in the 2.4 to 2.5 release when we switch to namespaces. There isn't any end-date to support of past versions. If some security issue turns up, It'll go into all current versions that we offer as downloads. For past versions that don't have active development branches, we would provide a file replacement or patch. To date, there have not been any security issues, so it's never been up to test. But it's always good to have a plan. We are very shy about changes that break things, so would version the API if behavior of some core functions changed from version to version. This is one reason why I think PW is a good/safe long term solution. The problem that I've run into with WordPress and Drupal is that I can't leave old versions of them running because the site is only as secure as it is up-to-date. Old version of WordPress/Drupal = insecure (not to mention the plugins). An installation of one of these products becomes a permanent relationship with the client as you have to continually keep it up-to-date, in the same way you have to keep filling up your car with gas or it stops running. This is not the case with ProcessWire. I still have 7+ year old versions of ProcessWire (aka Dictator CMS and PW1) running sites perfectly fine. I could upgrade them, but there isn't really any need to unless the client needs some new feature present in a newer version of ProcessWire. Being able to install a software and trust that it's going to keep running on it's own for a decade or more, without my intervention, is worth a lot.1 point
-
1 point
-
OK, it's been a while since I looked at this, and much of it was inspired or guided by Ryan. I had to boil it down a little to make it generic enough to make sense, so this exact code hasn't been tested, but it should get you started. Here's a proof of concept that works. Template for your calendar page <?php function pagesToJSON(PageArray $events) { $json = array(); foreach($events as $event) { $json[] = pageToArray($event); } return json_encode($json); } function pageToArray(Page $event) { $data = array( 'id' => $event->id, 'title' => $event->title, 'start' => date("Y-m-d H:i:s",$event->start_date), 'end' => date("Y-m-d H:i:s",$event->end_date), 'url' => "./$event->id", // event ID is the url segment ); return $data; } if($input->urlSegment1) { // event ID provided as a URL segment to this page $event = $pages->get("id=$input->urlSegment1"); include("./includes/head.inc"); echo $event->title; echo $event->body; include("./includes/footer.inc"); } else if($config->ajax && $input->get->start && $input->get->end) { // fullCalendar making an ajax request of events $start = (int) $input->get->start; $end = (int) $input->get->end; $events = $pages->get("/calendar/")->children("sort=start_date"); $events = pagesToJSON($events); echo $events; } else { //display the calendar $config->scripts->add('/site/templates/assets/js/fullcalendar.min.js'); $config->styles->add('/site/templates/assets/css/fullcalendar.css'); $config->styles->add('/site/templates/assets/css/calendar.css'); $config->scripts->add('/site/templates/assets/js/cal.js'); include("./includes/head.inc");?> <div id="calendar"></div> <? include("./includes/footer.inc"); } // end else ?> head.inc <!DOCTYPE HTML> <html> <head> <title><?=$page->title?></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- CSS includes defined via $config->styles->add --> <?php foreach($config->styles as $url) echo "<link rel='stylesheet' type='text/css' href='$url' />";?> <!-- include jQuery --> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js" type="text/javascript"></script> <script>!window.jQuery && document.write(unescape('%3Cscript src="/site/templates/assets/js/jquery-1.6.3.min.js"%3E%3C/script%3E'))</script> <!--js includes defined via $config->scripts->add --> <?php foreach($config->scripts as $url) echo "<script type='text/javascript' src='$url'></script>";?> </head> <body> footer.inc </body> </html>1 point
-
Hi Ryan. I installed the blog profile for someone else and of course, for set up and troubleshooting I have a superuser role for myself. I'm the kingmaker though and not the king and I'm never going to write a blog on this particular site (or anywhere probably) but when I go the the authors page I see my username. I didn't give myself the author role and I don't want anyone seeing my username on the site. It's someone else's personal blog and might lead to confusion. So.. I looked into the authors.php template and found: $authorRole = $roles->get('author'); $superuserRole = $roles->get('superuser'); $authors = $users->find("roles=$authorRole|$superuserRole, sort=title"); on line 33- 35 which explains it. I'm wondering now, is it as simple as removing that and leaving: $authorRole = $roles->get('author'); $authors = $users->find("roles=$authorRole, sort=title"); or would that create new problems. I read up on this thread and couldn't find anything on this situation, unless I missed it.1 point
-
1 point