Jump to content

Soma

Moderators
  • Posts

    6,798
  • Joined

  • Last visited

  • Days Won

    158

Community Answers

  1. Soma's post in Install error - Error: Exception: SQLSTATE[28000] [1045] was marked as the answer   
    But then no matter what you enter it does show the same error
    http://wire.madaboutbrighton.net/klajsdlas
    http://wire.madaboutbrighton.net/hello.php
    ...
    Currently the installer shows at 
    http://wire.madaboutbrighton.net/
    which normally would be at
    http://wire.madaboutbrighton.net/install.php
    There's no way I see why PW is causing this issue. It could be an already installed PW or an .htaccess somewhere. The database credentials are stored in /site/config.php after you entered them and when PW was able to connect to DB. 
    It doesn't matter what folder or sufolder PW is put. It doesn't try to connect to a db at that point as you haven't yet come to enter it. So something's wrong on the server and how you have set things up.
    If htaccess is already enabled, it is somehow already trying to route to the index.php, that's maybe why it would somehow already tries to load ProcessWire.php core. But there's no way PW already knows you're database.
    When I try to reproduce something alike, I can only get domain.com/randomstr to show a PW error but no sight of DB or ProcessWire.php. I can even delete the index.php and /core/ProcessWire.php and install PW fine to the very end.
  2. Soma's post in Use FieldtypeTextLanguage in module config inputfield was marked as the answer   
    This has come up already...
    Module config doesn't work with language fields. Since its stored as json and you are actually using inputfields here not fields. Look at LanguageSupportPageNames how it can be done.
    Apart from that your code would be wrong. It's InputfieldTextareaLanguage with inputfield type InputfieldTinyMCE.
  3. Soma's post in It looks so easy, checkbox was marked as the answer   
    Yes! A page field with multiple options, it's an PageArray.
    $pageArray->implode() is one utility to deal with it. Or just use on of the array methods you also see on cheatsheet.
    Others useful things are
    $page->pagefieldmulti->first()->title; Translates to:
    "currentPage->thepagefieldpagearray->thefirstinthearray->itstitle"
    Or in a foreach
    foreach($page->pagefieldmulti as $selected) echo $selected->title; Or to search and check for if a certain option is selected
    if($page->pagefieldmulti->has(1001)) echo "option page with ID 1001 is selected"; has($page) return true if the PageArray of the field contains the page you give it.
    $page->pagefieldmulti->has($someotherpage); Since the options of a page field are also pages, it may get clearer if you try to think of it as a array of pages. Many methods accepts various things like a string or object or int of an ID maybe even a path like "/some/path/to/a/page". 
    Just play and experiment with it and see what works.
  4. Soma's post in What is the shortest way to compare 2 WireArrays? was marked as the answer   
    Sorry, me again.
    This works too and may best option with page arrays where you have an id.
    if("{$a1->sort('id')}" == "{$a2->sort('id')}") echo "identical"; Sort them by id first and put into quotes to make them both a string, if string is same they were identical.
    To go further, you could extend the PageArray with a new method. This can be done with a simple hook. For example in your templates init:
    wire()->addHook("PageArray::compare", null, function($event){     $a1 = $event->object;     $a2 = $event->arguments(0);     $event->return = "{$a1->sort('id')}" == "{$a2->sort('id')}"; }); Then you can use it everywhere in your templates like this
    if($a1->compare($a2)) echo "identical"; If you the hook to an autoload module like the HelloWorld.module you could use this method throughout PW.
  5. Soma's post in Conflict b/w "Parent of selectable page(s)" and "Custom selector" was marked as the answer   
    Just don't specify a parent. It's not mandatory if you have template or selector.
  6. Soma's post in selector children of children was marked as the answer   
    And last some code when children would have their own template:
    $allChildren = $pages->get("/locations/")->find("template=child_tpl"); or even checking for parent template
    $allChildren = $pages->get("/locations/")->find("parent.template=parent_tpl"); or
    $allChild = new PageArray(); foreach($pages->get("/locations/")->children() as $parent) {    foreach($parent->children() as $child) $allChildren->add($child); } and there's even more variations depending on who writes it.
  7. Soma's post in Processwire Selector - limit levels was marked as the answer   
    With the MarkupSimpleNavigation you could do it like this:
    $opts = array(     "max_levels" => 3,     "outer_tpl" => "",     "inner_tpl" => "",     "list_tpl" => "",     "item_tpl" => "{id}|",     "item_current_tpl" => "{id}|"     ); $res = $modules->MarkupSimpleNavigation->render($opts); $res = trim($res, "|"); $allPages = $pages->find("id=$res");
  8. Soma's post in state and cities was marked as the answer   
    Field dependencies, .. not sure if that would work, as this would require to reload the second select. And field dependencies isn't able to define what the page field has for the parent. As kongondo mentioned not a trivial thing, and may require some magic ajax. But maybe not. 
    EDIT: My bad, I completely forgot this is possible in new version 2.4 with using a custom selector (as described in next post) I forgto about it and remember now Ryan mentioned it in some thread and to be forgotten...
    There's currently no out of the box UI solution. But you could kinda can make it happen with selecting the first select, save page, selecting the second.
    You can use the "custom php code" of the page fields "Input" settings tab. Instead of a parent or custom selector you would have this kind of code in the second select and read the saved value of the first.
    So reading again your post...
    If you have them nested as pages like:
    - state1
       - city1
       - city2
    - state2
      - city3
    Then the first select:
    "states_select" = is the page field single select to select states, using a parent or template.
    Then in the second select let's say "city_select", you would use such a code to populate the page select:
    if($page->states_select) return $pages->find('parent={$page->states_select}'); "$page->states_select" is the first select field on the current page. So if a page is selected there we will use a selector to get all children of the parent and return the page array to populate the second select.
    Edit: with some clever hooks you could add some javascript to the admin that handles the updating, either via ajax or adding an event listener for an on change of the first select and save the page by triggering the save button. 
    Don't try this as it can corrupt your page.
  9. Soma's post in Update relative paths in TinyMCE was marked as the answer   
    If you set the textarea to content type html, in the field settings, PW will take care of it.
    If you set the textarea to content type html, in the field settings, PW will take care of it.
  10. Soma's post in Detecting when pagination will kick in was marked as the answer   
    Just set to a variable and test if it got any markup...
    $pager = $a->renderPager(...);
    if($pager) $out .= "...";
  11. Soma's post in Best way to limit child depth was marked as the answer   
    Enable advanced mode config. Select fieldgroup underneath the fields from the original template instead of adding them again. It then references the fieldgroup.
    Or have a hook into the page list action to remove or don't allow 'new' from those pages that have certain level.
  12. Soma's post in paginating results generated from values in GET was marked as the answer   
    Just use $input->whitelist(key,value) to store get vars and pager will auto include it.
  13. Soma's post in Permissions Not Taking Effect was marked as the answer   
    I think he needs also edit access to articles to add children.
    I'm not sure I test and works fine here. Same as you set up but no page-publish permission, but works also with using it.
  14. Soma's post in Use textformatter in template was marked as the answer   
    You just get the textformatter module and use the formatValue(). It accepts Page, Field, String but you can also pass an empty page and field as most textformatters also don't use it except HannaCode I think.
    $str = $page->textfield; $modules->TextformatterModuleName->formatValue(new Page(), new Field(), $str); echo $str; This is deprecated, but should work for most textformatters still
    $str = $page->textfield; $modules->TextformatterModuleName->format($str); echo $str;  
  15. Soma's post in $user comparison odd behaviour was marked as the answer   
    Maybe turn on debug mode...
    ... (int) $user ...
    "Notice: Object of class User could not be converted to int"
    I'm not sure about the context where you say it doesn't work but these works always
    $user === $page->createdUser  (if same object)
    $user->id == $page->createdUser->id (if same id)
  16. Soma's post in Get template of page being edited was marked as the answer   
    $page = $event->object->getPage();
     
  17. Soma's post in weird chars on my page was marked as the answer   
    U need to set locale to utf8 like fr_FR.utf8
  18. Soma's post in Sanitizer pageName (and Translations?) was marked as the answer   
    It would be correct:
    $sanitizer->pageName("Größen", Sanitizer::translate); No it's not dependent on special thing. It's used to translate titles to the name. Nothing to do with translations. This was added at some point around 2.3 after lots discussion and isn't documented on API section (yet) but on cheatsheet http://cheatsheet.processwire.com/?filter=pagename.
  19. Soma's post in Back-End on SSL Connection Only was marked as the answer   
    Templates -> Filters -> Show System Templates : look for "admin" template. Edit and go to -> "URLs" and look for https etc.
  20. Soma's post in Delete all for file/images was marked as the answer   
    Double click the trash icon. Voila.
  21. Soma's post in Looking for some suggestions / help was marked as the answer   
    Then I would create a new template "user-order" add a single page field "product" and a datetime field to the template. Then create a new order with this template , and save it under the user page. I think you just need to allow children on the family settings on the user template.
  22. Soma's post in list the children of the page parent, but not the page itself was marked as the answer   
    $parent = $page->parent; $current = $page->id; $overviewchildren = $parent->children("id!=$current, limit=4"); Or maybe
    $overviewchildren = $page>siblings("id!=$page, limit=4"); Edit: oh and welcome!
  23. Soma's post in are there any programming experts on this forum? was marked as the answer   
    Pretty messy... I would try something like this:
    (function ($) {   $.fn.matchCarousel = function(data, options) {     var settings = { 'maxMatches': 10 };     if (options) { $.extend(settings, options); }     function customDataSuccess(data) {           var counter = 0;         for(var i in data["items"]){            var img = data["items"][i].img;            var alt = data["items"][i].alt;            content += "<img src=\"" +img+ "\" alt=\"" +alt+ "\">"         }         $("#owl-demo").html(content);     };     customDataSuccess(data);   } })(jQuery); $(document).ready(function() {     $("#owl-demo").owlCarousel({         jsonPath: 'data.json',         jsonSuccess: customDataSuccess     });     function customDataSuccess(data){         $(document).matchCarousel(data,{ maxMatches: 10});     } }); The callback function jsonSuccess doesn't allow for directly calling your plugin with arguments, but within the callback function you could easily pass "data" and other arguments...   Or little simpler and direct $(document).ready(function() {     $("#owl-demo").owlCarousel({         jsonPath: '/site/templates/scripts/data.json',         jsonSuccess: function(data){              $(document).matchCarousel(data,{ maxMatches: 10});         }     }); });
  24. Soma's post in specify redirect URL after redirecting user to login page? was marked as the answer   
    So you're using ProcessWire Admin login for frontend login?
    ProcessLogin is only meant for backend login, and it has only a GET id for editing pages. So the id (if set with ?id=1231) will get appended to the form action url. This will be looked for and redirect to the edit screen after login.
    ProcessLogin::afterLoginRedirect is hookable, so you could replace it depending on what user logs in. 
    After all since it looks like a front end login you should consider creating your own login form, where you have full control and don't let everybody see where your backend login is.
  25. Soma's post in Ampersand (&) breaks search and causes error was marked as the answer   
    That's a strange one. But There's anyway a couple strange things when using PW search with selectors sometimes.
    On my new blog http://soma.urlich.ch this doesn't happen and I have the same code. When I search for & it get's transformed to "&" and it finds results that contain no visible "&".
    On all other PW sites there's an error.
    On processwire.com if you enter "test&" you get some results and the first search entry "
    iPhone test
    is strange as it is a page that isn't viewable!
    Anyway, searching with like "some & string" isn't a problem, and maybe just a min char count test on the search form could easily prevent error for things like "&".
×
×
  • Create New...