Jump to content

diogo

Moderators
  • Posts

    4,296
  • Joined

  • Last visited

  • Days Won

    79

Everything posted by diogo

  1. The problem is in the conversion. the date you are getting is the beginning of the unix timestamp... can't be equivalent to that number.How did you do the conversion?
  2. Nice work Alan! Press releases page is a bit empty. Maybe you can add a conditional to check if there is a press release, and write something like "there isn't any press release to show yet" in case there's not.
  3. Wow, what a first post! I can't test it now, but it looks great! Although I don't understand a big part of it... i will get there I just don't like the hard coded language if ($lang == 'en') $lang='default'; Would be more elegant to have a setting on the module for this static public function getModuleConfigInputfields(array $data) { $data = array_merge(self::$defaults, $data); $fields = new InputfieldWrapper(); $modules = Wire::getFuel("modules"); $field = $modules->get("InputfieldText"); $field->attr('name', 'defaultLang'); $field->attr('size', 10); $field->attr('value', $data['en']); $field->label = "Default language"; $field->description = "What is the url code you want to use for your defaul language?"; $field->notes = "Example: en, pt, gr or it"; $fields->append($field); return $fields; } protected static $defaults = array( 'defaultLang' => 'en' ); $options = self::$defaults; if ($lang == $options['defaultLang']) $lang='default';
  4. Sorry, it wasn't clear that i was joking. Next time i will put more smileys
  5. calendar, weather, sudoku, stock market... i will tell more if i remember
  6. So, all your quotes are in one page, inside a repeatable field? sorry, because I still didn't get this. edit: in your code you never call the field "employee_quotes", to have access to "employee_quote", you should call it like this on the selector ("employee_quotes.employee_quote != ''") edit2: I know what is happening. because you are calling the fields inside of the repeater directly, and because these fields are inside the special repeater hidden pages, those are the ones that PW is finding on your first line. That's why you have results only when you are logged in as superuser. Give us some more details about what exactly you want to do. You have more than one page with the repeater "employee_quotes"? Anyway, in general this should work for what you want: $quoteList = $pages->find("employee_quotes.employee_quote!=")->shuffle(); $quoteList = $quoteList->shift(); $employeeQuote = $quoteList->employee_quotes->shuffle(); $employeeQuote = $employeeQuote->shift(); if ($employeeQuote) { echo "<blockquote>{$employeeQuote->employee_quote}</blockquote>"; } But would be less complex if all repeaters are in one page only
  7. It's good to frequently test your site while not logged in. Use a different browser from the one that you use to develop, so you don't have to be always logging in and out. If you use Chrome, you can also open an incognito window for this. Anyway, to make what you asked for on the default site, change these lines on foot.inc: // If the page is editable, then output a link that takes us straight to the page edit screen: if($page->editable()) { echo "<a class='nav' id='editpage' href='{$config->urls->admin}page/edit/?id={$page->id}'>Edit</a>"; } to: // If the page is editable, then output a link that takes us straight to the page edit screen: if($page->editable()) { echo "<a class='nav' id='editpage' href='{$config->urls->admin}page/edit/?id={$page->id}'>Edit"; if($page->is(Page::statusUnpublished)) { echo "<br>Unpublished"; // this adds the unpublished status to the edit button } echo "</a>"; }
  8. @arjen you are calling the repeater as if it was a normal field. What fields do you have inside it?
  9. $class = $child === $page->rootParent ? " class='on'" : ''; is a short way of writing if($child === $page->rootParent) { $class = " class='on'"; } else { $class = ''; } $page->rootParent gets the ancestor that is closer to the root (a direct children of the homepage). If you change the homepage variable to a something different from the root, they will never match. For this to work you have to replace $page->rootParent for this page's ancestor that is closer to /en/. Put something like this after the first lines: foreach($page->parents as $v) { if($children->has($v)) { $newRootParent = $v; } } Then replace $page->rootParent by $newRootParent. I'm not on my computer, and I can't test this right now, so, no guarantees here
  10. I think this is what you want $homepage = $pages->get("/"); $children = $homepage->children->find("visibility_in_top_menu=1");
  11. It's true, I gave it a try and it worked:) It returns an array with all the segments like this: ( [1] => segment1 [2] => segment2 )
  12. By the way, $input->urlSegments is not on the cheatsheet
  13. diogo

    the-omnia.com

    I still didn't comment on this site, but I must say, I love the "Philosophie" part
  14. AND would get all the pages, while OR gets the pages from the first part, and if there isn't any, it gets the pages from the second. It seems to work as expected. You should read it like this: created_users_id|modified_users_id=1009 // get all pages that were created or the pages that were modified by this user // (if the first is true, the second doesn't run) created_users_id=1009, modified_users_id=1009 // get all pages that were created by this user, and that were also modified by this user // (both must be true) Use AND for what you want.
  15. put a checkbox on the main page template (it's more efficient since you don't even have to call the other page) and do this: <?php if($page->checkbox){ $item = $pages->get("template=upcoming-exhibitions"); echo "<h2>{$item->title}</h2>"; echo "<img src='{$item->exhibition_image->size(100,100)->url}' alt='$item->description'/>"; echo "<p>{$item->exhibition_summary}</p>"; } ?> Or, if you still prefer to have the checkbox on the exhibitions page: <?php $item = $pages->get("template=upcoming-exhibitions"); if($item->checkbox){ echo "<h2>{$item->title}</h2>"; echo "<img src='{$item->exhibition_image->size(100,100)->url}' alt='$item->description'/>"; echo "<p>{$item->exhibition_summary}</p>"; } ?>
  16. @MadeMyDay are you still struggling with this? I came up with a solution that uses url segments... of course you would loose this functionality on your templates... You would only have to create an empty page for each language and assign it this template: <?php function toSlug($str) { $str = strtolower(trim($str)); $str = preg_replace('/[^a-z0-9-]/', '-', $str); $str = preg_replace('/-+/', "-", $str); return $str; } $lang = $page->name; $user->language = $languages->get($lang); $basePage = $pages->get("/"); $segments = $input->urlSegments; if($segments){ $page = $basePage; foreach($segments as $segment){ $children = $page->children; foreach ($children as $child){ $found = false; if($segment==toSlug($child->title)){ $page = $child; $found = true; break; } } if (!$found) throw new Wire404Exception(); } } else { $page = $basePage; } include("./{$page->template}.php"); This is all it does: Changes the language to the name of this page (page must have same name as correspondent language) For each url segment, it converts the title to a slug format, and looks for the children with the same name. On the last segment it changes the $page object to the correspondent page object. If no page is found, throws a 404. Includes the template from the original page. Maybe you could combine this with Ryan's solution for the URLs
  17. Do this test to see if everything is working properly concerning security
  18. I didn't test a lot. I really didn't do more than described on my post. But yes, with this limited test, It's working as it should.
  19. Tested before and after updating. Before updating all the repeater fields were deleted when i cloned the page. After the update it didn't happen anymore.
  20. I think this is how it works with Oliver's module. Also works like this with the repeatable fields. Shouldn't be too difficult to do it. They could even be hidden from editors. I still have a problem with the links. Since I replaced the $page object by the original page, $page->children, gives me the children of the English page. It would be easy to solve by creating a myPage=$page instead of replacing $page. But would be nice to do all this without even having to change the already written templates.
  21. I tested the code that I posted above, and it works great I updated it with some changes that I did while testing. The navigation works like a charm with this change.
  22. For email there's also swiftmailer, anyone used?
  23. I never install a new one, Just move and change the config.
  24. This may seem a bit hackish, but you could have multiple trees but keeping one main tree with all the fields of all languages. The other trees would be there only for constructing the urls. There doesn't have to be any field on their pages. The template for each of those pages can call the fields from the corresponding page from the main tree. So, for having the kind of urls you want (domain.com/en/products/productA), on your template you could do this (not tested): (--Assign this template to all the pages in the language trees--) // Here I will assume that English is the default language, and the main branch of the tree $de = $pages->get("/de/"); $pt = $pages->get("/pt/"); $parents = $page->parents; // An array with all the ascendants of current page if ($parents->has($de) || $page->name == "de") { // If current page is under /de/ $lang = "de"; } if ($parents->has($pt) || $page->name == "pt") { // If current page is under /pt/ $lang = "pt"; } if (isset($lang)) { // If not the default language -> change from if($lang) to if (isset($lang)) to prevent errors // Change to the correct language $user->language = $languages->get($lang); // Now we have to convert the $page object in the correspondent page from the main tree // I'm using a pagefield now (just include a pagefield on the template and choose the corresponding page from the main tree) $page = $pages->get("$page->pagefield"); } include("./{$page->template}.php"); // includes the original template file On the head, change the navigation to: (here i used the default theme as example) $homepage = $pages->get("/"); if (isset($lang)) $homepage = $pages->get("/$lang/"); Maybe this is confusing, and maybe not easy to deal with links later, i don't know... I will sleep and see if it still makes any sense in the morning edit: I did some changes in the code, The most important are: using a select page field, including the original template, and fixing the navigation
×
×
  • Create New...