Jump to content

Adam Kiss

Moderators
  • Posts

    1,303
  • Joined

  • Days Won

    7

Everything posted by Adam Kiss

  1. Hello, welcome to forums. I'll let Ryan answer this one, but I'm just curious: do you have any reason why you would like to accomplish this, or is it simply matter of personal preference? Adam
  2. I think I have an answer for you: set permissions for ./site/ to 766 too! Having this dir tree: processwire / site : 444 (dr--r--r--) / assets : 766 (drwxrw-rw-) If /site/ is set to 444 only, it might not let you create files in subdirectories (based on your Apache/PHP settings). So you might want to check out it's permissions too and preferably set it to 766 or 777 too. Edit: If PHP running script has the same GUID as apache, the user part (the first one) is crucial (there must not be 4). If not (some hosts do not have the same GUID for apache and PHP scripts running on it), the rest is important too
  3. Looking at the results, is it possible, that your hosting has blocked PHP functions like 'mkdir()' or 'chmod()'? If you can't create directory (although 766 on assets directory), the rest will fail. Is it possible?
  4. Don't worry, Ryan's solutions aren't always the best ;D ;D ;D
  5. Hi Rith0s! Isn't there actually a video??? Anyway, I'll try to clarify a little here: 1. thing to know: one template in admin = one template file in /site/templates/. Whatever content is using this template, PW will try to parse contents of page through that php file. 2. template consists of PHP code to pre-process data and HTML output. HTML output (for convenience) can be also in external code called with require/include/flush or any other method, so you modify just one master template. 3. PW2 gives you few global variables to use in your template: $page (current page, it's fields [also in global $fields], and various (and some advanced too!) methods) $pages (connector to PW2 page tree) $input $session $sanitizer Full list with explanation here: http://processwire.com/api/variables/ More info about templates: http://processwire.com/api/templates/ Also, here is one of my templates with comments (hope it helps): <?php /* * Template: members.php * * Shows list of members based on date */ require_once '_inc/_functions.php'; //various functions if (!empty($page->body)){ //if we have $page->body (i.e. if field 'body' is filled) $o = new OutputArray('<h1>Heading 1</h1>'); //OutputArray is my own class. It's just an array to put strings into and then output on one place, //because it's faster than multiple $string .= 'addThis'; $o->add('<div class="tinymce">'.$page->body.'</div>'); }else{ $o = new OutputArray(); } $o->add('<h2>Heading 2</h2>'); $o->add('<ul class="clenovia">'); //here I get one page (by url) and then all of it's children (which is my members template, grouped in group 1) into $clenovia $clenovia = $pages->get('/s/clenovia-zboru/')->children('sort=sort'); $i = 0; foreach($clenovia as $c){ $foto = $c->foto->size(160,160); $o->add(s(CommonHTML::getPart('clen_zboru'), false, (++$i%3===1)?' class="cl"':'', $foto->url, $c->title, $c->uloha ));//here I ouput HTML for each of members of group 1 – s() is my shortened sprintf() function } $o->add('</ul>'); $o->add('<h2>Pravidelní spolupracovníci</h2>'); $o->add('<ul class="clenovia">'); //here I get another pageand then all of it's children (members, group 2) into $clenovia $clenovia = $pages->get('/s/pravidelni-spolupracovnici/')->children('sort=sort'); $i = 0; foreach($clenovia as $c){ $foto = $c->foto->size(160,160); $o->add(s(CommonHTML::getPart('clen_zboru'), false, (++$i%3===1)?' class="cl"':'', $foto->url, $c->title, $c->uloha )); // output HTML again } $o->add('</ul>'); /* * OUTPUT */ include("./head.inc"); // here I include $page headers – <head> section, <body> opening, navigation and everything BEFORE content // Not really necessary, but wanted the markup to line up with where it left off in header include, // so put four tabs before the bodycopy before outputting it: – I left here Ryan's template text. I am rebel! echo "\t\t\t\t".$o->render(); include("./sidebar.php"); //my sidebar custom code (which again works with $pages...) include("./foot.inc"); //end of content <div>, GA, </body> and that's all folks I tried to add as much comments as I can, although I'm not sure I made myself particulary clear But I sure hope it helps
  6. As we are talking about JS, please fix the JS title->url convertor too!
  7. Hi noodles, thanks for noticing I'll fire up e-mail (or set it up on github). I actually located the problem, So I'll give Ryan more info. Adam
  8. Hi Mike, if you check the code, it seems there are two different paths referenced: one is /sub/ directory in your domain dir on server, the second one is DOCUMENT_ROOT itself. Now, this is somewhat unusual situation; Where the incorrect rootUrl comes from - it's easy: _/content/Hosting/d/i/digimute.com/subdoma|ins/lab/web -/content/Hosting/l/a/lab.digimute.com/web| note: I added the pipe character "|" to let you see where the 'substr' happens. On most servers, the DOCUMENT_ROOT would identify itself as '/c/H/d/i/digimute.com/s/lab/web/' (long words ommited), so the rootUrl would be pure '/'. But somehow, your host gives two totally different directories. I think your best bet for now is to hack the core (= put $rootUrl = '/'; after this code). And maybe post your var_dump($_SERVER), so we can compare it to default Apache $_SERVER contents and come back with some more bullet-proof code. Adam
  9. Great, thanks Noodles! I believe that Ryan will move this into FAQ section as helper how it could work.
  10. Glad to help, stick around Btw, for future reference (to better yourself at google searching ) complex syntax: http://lmgtfy.com/?q=curly+brackets+parsed+strings+php & operator: http://lmgtfy.com/?q=single+amp+operator+php in both cases, first links provide better understanding of things mentioned
  11. Hi, welcome to forums! This should be .htaccess documentation on ZEUS 4.3. Although quite old, seems that it's still 'active', i.e. still works. http://support.zeus.com/zws/media/docs/htaccess/tutorial.html Good luck and let us know if it helps and how far you got!
  12. Just a note from wiki about performance Queries using nested sets can be expected to be faster than queries using a stored procedure to traverse an adjacency list, and so are the faster option for databases which lack native recursive query constructs, such as MySQL[4]. However, recursive SQL queries can be expected to perform comparably for 'find immediate descendants' queries, and much faster for other depth search queries, and so are the faster option for databases which provide them, such as PostgreSQL[5], Oracle[6], and Microsoft SQL Server[7]. Seems nice.
  13. Hi Apeisa, welcome to the forums, although google is your friend in this case, I'll be easy on you {} brackets Is so called Complex syntax. It allows you to use more complicated $values in parsed strings, consider following: echo "$arr['foo'][4]"; throws syntax error, unexpected T_ENCAPSED_AND_WHITESPACE echo "{$arr['foo'][4]}"; on the other hand, will work, because the curly brackets delimited parts of string, that should be considered as $variable. More here: http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing.complex P.S.: even simple parsing can parse objects ($object->property), but I think Ryan considers it best practice to use curly brackets (not to mention it also increases readability) & operator Amp in this case is so called Bitwise And. You can read about it here: http://www.php.net/manual/en/language.operators.bitwise.php In this case, it compares two int values – page.status and value 1024. is page.status has the '1024' bit set (= if page.status value is 1 in binary form on 210th place) it continues.
  14. @slabbe: That sounds like some server/virtual server misconfiguration – it goes to absolute URL /url/something, but instead having /var/www/test.local as root, it thinks /var/www/ I'm not going to ask you whether it worked before , but maybe post a little about your LAMP stack too?
  15. Hi Snakehite, welcome to forums. 1. Currently there is no option of multiple languages (i.e. one tree with pages with multiple languages). However, there is an option how to do it (How am I currently doing it): you'll create your languages as subpages of root – e.g. '/es/' for spanish tree and '/en/' for english tree and continue as if you administrated two separated sites (one for spanish and one for english) Unfortunately, this system needs a bit of more of your attention to keep the trees mirrored (so every /es/ URL has its opposite in /en/ branch) for common parts of templates, e.g. footer and header and site title, I created one custom template with few textareas, called it 'various-parts' and have it hidden in each language branch, then in template you do something like $partials = $pages->get($language.'/various-parts/'); For starters, it is a bit awkard, but it'll work. We're trying to come up with a better solution with Ryan, but if you have any ideas hwo to make it work, let Ryan know. 2. Noted (and I already told Ryan a while ago , but there is other stuff to do right now – you could even use your own admin theme if you wish 3. as for contact form, I'll let Ryan answer that part (I haven't set up contact so far, so I'm no sure), but as for gallery – just have 'images' field, which gives you an array of images. Just let it output in your template, where you can use whatever client-sdie code you wish. (I'm currently setting up custom jQuery Cycle gallery – http://malsup.com/jquery/cycle/ for example. Adam
  16. Hi, let's say we have a Pages object as a result of get: $menu_items = $pages->get('/navigation/')->children(); foreach($menu_items as $item){ ... And now we want to 'unshift' and 'push' one items into this object: $menu_items = $pages->get('/navigation/')->children(); $home = $pages->get('/home/'); array_unshift($menu_items, $home); $item2 = $pages->get('/item2/'); array_push($menu_items, $item2); foreach($menu_items as $item){ ... This obviously won't work, since '$menu_items' is not an array (well, not so obivously... I just tried it.) So, my question is, how can we modify pages object to include (/not include) items? (without modifying site tree) Adam P.S.: It just hit me... can we do something like: $pages->get('/navigation/','/page/','/item2/')
  17. This is wonderful information and I believe it fits into FAQ section (having just to have config-dev.php is nice, although I will probably prefer URL based decision–easier to maintain with good–ol' FTP / auto-sync editor (e.g. coda)) Adam
  18. I was looking for the first time move also – what do we do? copy everything on server, create backup of staging database and then? what files to change (because database settings of server, where PW2 was installed and developed (either dev or local) probably has different settings than live server) And in addition, there are people (like me), who use shared hosting for some sites (in here, it's much more efficient in speed, price and reliable than cheap virtual), so they might not be ssh but the part of copying data between servers is the less important – moving from staging to live for the first time it's important! (i.e. in wordpress, you have to backup, edit and copy files in selected order, otherwise you have a problem) Adam
  19. Hi Ryan, is it possible to hack something in PW, so it will work on two different servers? (staging AND live server) something like (pseudocode): $LIVE = (set_by_url) ? true : false; if($LIVE){ $db = 'hujul'; $db_user = 'user'; $db_pw = 'pw'; $db_server = 'this-one.com'; }else{ $db = 'staging-db'; $db_user = 'root'; $db_pw = 'root'; $db_server = 'staging.that-one.com'; }
  20. Hi Ryan, could you write a little tutorial about how to safely move PW2 Install from staging server to live server? Thank you, Adam
×
×
  • Create New...