Jump to content

LostKobrakai

PW-Moderators
  • Posts

    4,956
  • Joined

  • Last visited

  • Days Won

    100

Everything posted by LostKobrakai

  1. You can get the timestamp of $page->week_begin with $page->getUnformatted("week_begin"). With the timestamp you can easily use all the php date functions, which includes stuff to add a few days: http://de1.php.net/manual/en/ref.datetime.php.
  2. There is a difference between an html/css template vs. the ready to install templates. I can see the simple html/css ones as a good starting point, if the budget is limited. From there you use the base to iterate further to the final product. The readymade ones, on the other hand, mostly seem more closed to own additions and tighter cuppled to specific forms of data, which isn't that great.
  3. I just now got the joke within the avatar
  4. https://uberspace.de/ is a shared hosting which doesn't have ftp
  5. I still didn't grasped what you're trying to archive, because your last code piece was missing, so I tried to help you with what could be what you're after. As long as you include the _init.php in each template there shouldn't be any error in echoing the $sort variable, no matter where in your code. There must only ever be the include statement somewhere before the echoing.
  6. First of all $page->get("extrainfo").$sort; doesn't make much sense on its own. If you want to dynamicly build the name of the field to query use this: $page->get("extrainfo".$something); But I still can't get my head around what you're trying to archieve. A field can't be sorted. Only array's or in pw pagearrays. If extrainfo is a page field or a repeater, you can use this. $page->extrainfo->sort($sortSelector); Edit: Read your first post again. If you just want to append $sort to the string this should work: $page->get("extrainfo").$sort; Either you get only the field or with $sort appended, if it is overridden from it's empty init state.
  7. You're echoing $content while setting $sort, so there' still something missing in your example.
  8. Most people here use a delageted approach to templating which in short looks like this. This will either echo nothing or your default value, if present. More info on this approach can be found here: http://processwire.com/docs/tutorials/how-to-structure-your-template-files/page4 // _init.php $sort = ""; // template.php include "_init.php"; $sort = "sort by date …"; include "_main.php"; // _main.php […] echo $sort; […] If you don't use this way of templating, the thoughts behind this is, that you have a php file which is always called before everything else, where you define all your variables. Then you don't get the php error for undefined variables if you just echo them. Everything after this file then overrides the empty string to actually display stuff in places where the variable gets echo'd.
  9. All the variables coming from the pw api are not really single variables but properties and methods of an object. Therefore they return NULL if you try to get an non existent property and an php error if you try to call a non existent method. So for the api stuff " if($page->randomProperty) … " is most of the times enough, while for normal variables you have to go with " if(isset($stringVariable)) … ". If you really only want to check on the existance of an property you need to do the following, because otherwise the if statement would also not hit, if the randomProperty is false. if($page->randomProperty != NULL) Maybe use double quotes? This could lead to errors because of missing quotes, if somebody manually copies it.
  10. There are reasons, because it's not only about what's being transfered, but also who is transfering data to whoever else. But I don't think that should matter in this case.
  11. You could do this yourself, if your using processwire > 2.4. The admin theme is a module there, which you could copy in your site/modules/ folder and modify it, to show your submenu. Then choose it in the backend to be your admin theme and your done.
  12. I think the issue, why this doesn't exist in this form, is that, according to the pw core priciples, most people here don't want to glorify one way of solving things, but much rather tell you how to do it yourself. I can understand that this is not the best way to appeal to newbies and I also think there could be done more to ease the entry of working with pw. One would like to have a big teaser image on their blog, while others want a "x" layers deep categorization for their thoughts. If you want to add all possible scenarios you'll likely end up with bloat. Most other CMS's out there just tell you which content you have to use. A standard Wordpress installation can manage exactly four types of content: articles, pages (more or less the same as articles), comments and "media", while telling you how all those type should look like. It just gives you a blog. Only all those plugins try to make it something more.
  13. @OrganizedFellow Maybe just exclude contents of those folders, so the folders themself get pushed to your git server.
  14. I think you don't need all those finds. You just need to build the selector string the right way. "template=member-profile, fieldname=$filter, sort=-name" translates to "find all pages with the template 'member-profile', where fieldname is '$filter' and sort the results by name ASC" If you just want to sort your $filter variable from your code, maybe just do $filter->sort($sort);
  15. Maybe it would be useful if you would be more descriptive in telling us what this filter should do. From reading your first post a few more times, it seems you want to sort your filtered results. Your code seems to do exactly that. If you want to sort an existing PageArray you can simply do: $pageArray->sort("-name");
  16. My code was an example so do this by the api. The $templates variable was so conveniently named , as said didn't tested it
  17. I think the project is still in developement and not intended to be live.
  18. Maybe this? $selects = $pages->find("template=member-profile")->find($filter)->sort($sort);
  19. Websites often provide content not only as on list of stuff, but with some sort of category. The most flexible way in ProcessWire to manage such a categorization are with PageFields. Form example with a structure like this. - Magazine (magazine) - Articles - Article 1 (article) - Article 2 - Article 3 - … - Categories - Category 1 (category) - Category 2 - … Templatenames in parentheses Now all articles have a url structure like: "…/magazine/articles/articlename/" The categories are looking like: "…/magazine/categories/categoryname/" But it can be useful to also provide the articles as part of the categories like this: "…/magazine/categories/categoryname/articlename/" Because ProcessWire doesn't provide such functionality by default, we'll use urlSegments. These have to be enabled in the template-settings for the category template. This template therefore fulfills two different jobs. Displaying a list of containing articles, as well as rendering the articles which are linked by the list. A simple example of a existing category.php could be: <?php // category.php $articles = $pages->find("template=article, category=$page"); // This example uses a deligated template approach. // Feel free to use your own way of templating, // but this is also a simple way to explain this. $content = renderArticleList($articles); include("./_main.php"); Now we need to include the logic to seperate the default rendered article-list to the now added rendering of the called article. <?php // category.php // Throw a 404 Error if more than one segment is provided if($input->urlSegment2) throw new Wire404Exception(); if($input->urlSegment1){ // Show the called article // Sanitize the input for pageNames $name = $sanitizer->pageName($input->urlSegment1); // Search for the article with this name $article = $pages->get("template=article, name=$name"); // Throw an 404 error if no article is found if(!$article->id) throw new Wire404Exception(); // Explicitly set the original url of the article for the <link type="canonical" href=""> tag $article->canonical = $article->url; // Render the page, like if it was normally called. // $page->url will not updated to the "categorized" url for the rendering-part // so you need to have that in mind if you provide some sort of breadcrumb echo $article->render(); }else{ // Show the list of articles of the current category $articles = $pages->find("template=article, category=$page"); // The generateCategoryUrls() function is new, because // $page->url would provide the wrong urls. // Details are provided later $content = renderArticleList( generateCategoryUrls($articles, $page) ); include("./_main.php"); } Now if we call this "…/magazine/categories/categoryname/articlename/" we'll get the right article rendered out instead of the article-list. Now we need to talk about the article-list, which would - without changes - still render the "wrong" urls to all those articles. Therefore I added the generateCategoryUrls() function. This function iterates over the pageArray and adds a second url to all those articles. <?php // part of _func.php function generateCategoryUrls($list, $category){ foreach($list as $item){ $item->categoryUrl = $category->url.$item->name."/"; } return $list; } The last thing missing is the actual template which gets rendered by renderArticleList(). This would normally call for $article->url to get the url to the article. We want this to render our second url if we are on a category site. To let the template still be useable by non category sites, we just change the parts, where to url is used form the current $article->url to $article->get("categoryUrl|url"). Only if the additional urls are provided they get rendered or it falls back to the normal urls of the articles. There we go, with such a setup all categorized articles are reachable via both urls. A small addition to explain the $article->canonical I used in the category.php. For SEO it's not good to provide the same content on multiple pages without explicitly declaring which of the duplicated ones should be the original / indexed one. By providing the following link tag we provide this declaration. The extra field I use isn't really necessary, because $page->url still is the standart ProcessWire url of the shown article. But I like this to be visibile in the code, that this is a dublicate. <link rel="canonical" href="<?php echo $page->get("canonical|url") ?>"/> Hope you like the explanation. Feel free to give feedback on this. Based on the example shown in the wiki: http://wiki.processwire.com/index.php/URL_Segments_in_category_tree_example
  20. @Pavle Haven't checked if it works, but it should get you going. Edit: Please look at Soma's post: https://processwire.com/talk/topic/7544-ideas-for-linkbutton-fieldtypeinputtype/#entry72694 $templates = array(); $templates[] = $templates->get("templateName1"); $templates[] = $templates->get("templateName2"); $templates[] = $templates->get("templateName3"); $templates[] = $templates->get("templateName4"); foreach($templates as $template){ $template->fields->add("fieldset"); //use the fieldnames $template->fields->add("text_language"); $template->fields->add("page"); $template->fields->add("fieldset_END"); $template->save(); }
  21. You could simply write a small php script, which includes all those fields to selected templates via the api. Only rearranging would be manual work.
  22. I think he meant importing both files in two different databases and export them with the same settings, then they should be compareable.
  23. That's exactly what I did now. In the relavent templates I just call this, to get the changed value. $page->get("link|url"); I used this to have a two way url structure for categorized content: "…/articles/articlename/" and "…/category/categoryname/articlename/". Thinking about writing a short tutorial for this.
  24. Are you getting any errors with debug mode enabled? Which version do you run? Also I think you would get easier feedback from Ryan, if you post a issue at github.
×
×
  • Create New...