Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/30/2012 in all areas

  1. Ok, i did it I put a repeater inside itself just to see what would happen, and the result is not pretty. As soon as you create a page with it, it creates a big number of repeater pages and breaks the system. It would be better if PW would just disallow this.
    2 points
  2. This was one of the resources that as soon as I looked at it, it kicked me from a looker to a doer with PW. Fantastic resource Soma. Thanks. I have worked with many CMS's and clarity (good clean documentation) is a very crucial aspect to get people involved and to stay with a project. I give 5 out of 5 stars to PW for this. I look forward to helping where I can.
    2 points
  3. Something like this then, but I've chopped a lot of code away to just give the essentials and therefore it might need some testing first. I'm also aware that there could be some better error checking too. Something like this should be at the top of your news template before including the head.inc file, as if you put in a year with no articles manually into the address bar, or mis-spell a month name or type in garbage then it should redirect you to the root news page: if ($input->urlSegment2 && strlen($input->urlSegment1) == 4) { $input->urlSegment1 = (int)$input->urlSegment1; $input->urlSegment2 = (string)$input->urlSegment2; if (in_array(strtolower($input->urlSegment2), array('january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'))) { $monthnum = date('n', strtotime('1 ' . $input->urlSegment2 . ' ' . $input->urlSegment1)); $filter = ', publish_date>' . mktime(0,0,0,$monthnum,1,$input->urlSegment1) . ',publish_date<' . mktime(0,0,0,$monthnum+1,1,$input->urlSegment1); } else { $session->redirect($pages->get('/articles/')->url); } } elseif ($input->urlSegment1) { $input->urlSegment1 = (int)$input->urlSegment1; if (strlen($input->urlSegment1) == 4) { $filter = ', publish_date>' . mktime(0,0,0,1,1,$input->urlSegment1) . ',publish_date<' . mktime(0,0,0,1,1,$input->urlSegment1+1); } else { $session->redirect($pages->get('/articles/')->url); } } And then where you want your archive links you'll want something like this to build an array of years and months: $dates = array(); $articles = $pages->find('template=news, sort=-publish_date'); foreach ($articles as $article) { $articletime = strtotime($article->publish_date); $articleyear = date('Y', $articletime); $articlemonth = date('F', $articletime); if (!isset($dates[$articleyear])) { $dates[$articleyear] = array($articlemonth); } elseif (!in_array($articlemonth, $dates[$articleyear])) { $dates[$articleyear][] = $articlemonth; } } And finally, to output your list of links, something like this (but check the $rootNewsPage variable): <ul> <?php $rootNewsPage = '/news/'; // Set this here somehow - my code did something complicated so you'll want something simpler like this probably foreach ($dates as $year => $months) { $class = ($input->urlSegment1 == $year) ? ' class="active"' : ''; echo " <li><a href='" . $rootNewsPage . $year . "/'{$class}>" . $year . "</a>"; if ($input->urlSegment1 == $year || (empty($input->urlSegment1) && $year == date('Y', time()))) { echo "<ul>"; foreach ($months as $month) { $class = ($input->urlSegment2 == strtolower($month)) ? ' class="active"' : ''; echo "<li><a href='" . $rootNewsPage . $year . '/' . strtolower($month) . "/'{$class}>{$month}</a></li>"; } echo "</ul>"; } echo " </li>"; } ?> </ul> That last bit should also put a class called "active" on the links so you can highlight which year/month you're viewing. So there we go, not the prettiest but it should be more or less functional. I'd love to know if there's a better way than looping through all articles though, but I suspect that's a necessity. The only way you'll be able to get around what seems like an expensive selector (especially if you end up running through thousands of articles further down the line) is to cache it somehow and make a module so that it's only ever re-built on page save or even via a CRON job - something I've been meaning to do for a while now. If you cached an array of the month then in theory such a module would simply need to read in that cache file and append a month and occasionally a year as necessary rather than iterating through ALL of the pages - much more efficient on larger sites so I might look into that. Funnily enough I've already got a home-brewed module called ContentCache that caches various bits and pieces like this already
    2 points
  4. I finally started a Cheatsheet for ProcessWire2.1+ Now it's also on processwire.com (auto fetching it from git) http://www.processwi.../api/cheatsheet The github project page: http://somatonic.git...WireCheatsheet/ And there's the git repository: https://github.com/s...sWireCheatsheet I'll continue to add or remove things as times goes by. At some point this will get converted to a PW App. 02.06.2012: - added with $input->urlSegments - added support for GET param in url to &filter and set &advanced - added support for hash in param to filter section 06.02.2012: - updated urlSegment($n) description to avoid confusion - remove some of the alternative syntax 17.12.2011: - added new section "Files" to the sheet - minor structuring of some advanced entries 08.12.2011: - added fix to menu when scrolling - moved some entries to advanced mode - added toggle button on sections - minor changes 04.12.2011: - some restructuring, adds and removes - minor tweaks overall, typos, ordering - added "advanced" mode 27.11.2011: - Added index collumn on left side - You can now toggle sections using the index - Also toggle show/hide all description of a category when clicking on blue titles. - It resets all if you click in the table somewhere (in white space) ADVANCED mode: Mainly it started with only "System Configurations" being advanced, but I added many of the more advanced functions overall. I don't know if it really is the thing to go, but I thought why not try to have very simple and basic version so it would fit on a matchbox . So they're my guess on to what would be the more advanced stuff, and I had kinda hard time to decide what to do and how. After long back and forth I decided to just give it a go and see what people think. Filter I noticed that in mozilla, the live search filtering wasn't working after the changes i've done to it. I figured mozilla has no innerText, which is very practical to get content of a node but not subnodes. I had to use textContent, which returns all text including subnodes, so the search filter doesn't work as good as in other Browsers. May I find a way to work around it. *Found that restructuring the markup was the only way to solve this problem. It should also now work much better in FF for the live search. --- Bug reports, feedback and suggestions are always welcome. Hope you like it!
    1 point
  5. Ajax Search 1.1.0 There was a request for a ajax live search. So I went and created a simple module. Added in 1.1.0 * added key support for browsing results with arrow down and up. * added escape key to close results. * added close results on click outside http://modules.proce...es/ajax-search/ From the readme: This module progressively enhances the search form to an ajax live search. It will perform a search like you would use the form normally, and returns the output of the search page. So the search will still work without js enabled. There's some basic styling attached to this module in the "styling-example". You can use it to get started. See readme in there. Setup the search.php So it works almost out of the box with the basic install profile of ProcessWire, you only need make a minor change to the search.php template file to only return the content part (results) on a ajax request. To get the ajax search only return the content, open search.php and change the output on the bottom to this: ... if(!$config->ajax) include("./head.inc"); echo $out; if(!$config->ajax) include("./foot.inc"); Module Settings It comes with some module options to define various settings regarding the search form. Following a list with the defaults. Minium length = 3 min length for starting ajax request Close button text = 'close' close button text ID of searchform = #search_form if you have a different search form id,class ID of input = #search_query if you have a different search input id,class Query name = 'q' this is the default param name as_query_url = '' if left blank the script will take the action of the form Any help testing this module is appreciated. If you have any questions or problems setting this up feel free to ask here. Also feel free to use this as a starting point for your own, or take out the script to implement it differently. It's quite simple and can be adapted really quickly.
    1 point
  6. Found PW through a tweet! Was looking for a clean and streamlined CMS to migrate MODx evolution sites from as the dev team replaced it with Revolution which was too big and heavy for smaller marketing sites IMHO. I have deployed sites on Drupal, MODx, EE, Pyro CMS and can tell you that for many of the types of sites we build, PW is a better match. Currently converting a +150 page site over now and scoping a few more.
    1 point
  7. Hi All, I am wondering if it would it be possible to use the new language features in 2.2 to create different versions of content for mobile devices and tablets. Detect on the front end and redirect to the right "language". That way you could have content optimized for device groups. I know Adobe has taken this approach with there BC platform. I have not looked in to the language features yet as I am new to PW and just getting my feet wet. @Ryan - Fantastic project. Excellent documentation. Impressive forum participation. Wow. I usually build highly structured sites and PW fits that like a glove plus it looks like a winner for marketing sites / landing pages. Impressed and thankful. Cheers.
    1 point
  8. This template was made before the column feature was introduced. So look in the code, the columns have a special class (guess something with "column", I am not at my computer now). Just apply a "float:left;" to that class in the admin's CSS. edit: I think it is the class "InputfieldColumnWidth". Look for that in the ui.css or add this: .Inputfields > li.InputfieldColumnWidth { float: left; clear: none; margin-top: 0; margin-left: 1%; } .Inputfields li.InputfieldColumnWidthFirst { clear: both; margin-left: 0; }
    1 point
  9. Update: I now have PW running on nginx. It took a little longer than expected & I'll post more when I've investigated it further.
    1 point
  10. I totally agree. I've always just used the code itself as my API reference, and it is SO much easier to just keep a window open to the cheatsheet.
    1 point
×
×
  • Create New...