Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/24/2019 in all areas

  1. How about this: <?php $p = $pages->findOne(1241); if ($p->id) : ?> <a href="<?php echo $p->url() ?>"><?php echo $p->title() ?></a> <?php endif; ?> Perhaps it's only a minor optimization, but it saves it returning any page object if the page isn't published. Be sure to read the docs on findOne() vs get() to understand fully, but basically find() and findOne() won't return unpublished pages unless to specifically request them to, but get() will ignore unpublished and hidden statuses and always return a page if everything else matches.
    2 points
  2. <?php $p = $pages->get(1241); if (!$p->is(Page::statusUnpublished)) : ?> <a href="<?php echo $p->url() ?>"><?php echo $p->title() ?></a> <?php endif; ?> https://processwire.com/api/ref/page/status/
    2 points
  3. Indeed, that was my aim originally - I didn't want infect you with my confusion... In the meantime I decided to accept that user foo would have view (not edit) permission to all the public pages. Important is that no guest user has access to the special page XY. Many thanks for the help.
    2 points
  4. No, I'm asking because if you are logged in and it works it might be because caching is disabled when logged in. On DEV caching is likely also disabled so that could explain why it works there. Is the not-working form somewhere online to check?
    2 points
  5. ?Hi ! This comment put me on the right track. It's solved. (The incognito window didn't worked. Yes I developed the site myself but I am not a developer.) I finally found the problem. I think the.htaccess file was incorrectly configured. I replaced it with another one and it worked. I must have changed something in there when I was trying to change my password... Thank you all for your help. Anton
    2 points
  6. --- Please use RockFinder3 ---
    1 point
  7. @Sergio Wow. This is working. I am no php expert. I am always having trouble on this... But I am on my way to get more comfortable on working with variables.... Thanks a lot! <?php $p = $pages->get(1241); if (!$p->isUnpublished()) : ?> <a href="<?php echo $p->url() ?>"><?php echo $p->title() ?></a> <?php endif; ?> yup - tested! The short version works 100%!
    1 point
  8. There's also a shortcut: if (!$p->isUnpublished()) :
    1 point
  9. Now you can join any finder to any column of another finder. That's quite powerful but might also get complicated or slow... It's especially handy when you want to use RockFinder2 as datasource of a RockGrid, because RockGrid does not support the new concept of relations that where introduced to RockTabulator https://github.com/BernhardBaumrock/RockFinder2/commit/8c6b66ad3dda68de9c1008078420f13a034250bf
    1 point
  10. Could you please explain by example what you are trying to achieve? At the moment I understood you like this: Public users should be allowed to view all public pages, but not page XY User foo should be allowed to view ONLY page XY (template bar) but not all public pages Same here. Or I didn't understand you ?
    1 point
  11. If I use TracyDebugger and run this: $page->of(false); $page->images->add("https://66.media.tumblr.com/f4958343844738fa507dc53d6493c988/tumblr_pszpc6YZF51uoauero1_1280.png"); $page->save(); It works fine ?
    1 point
  12. Why not use $user->isLoggedin() for the new role in your template
    1 point
  13. @a-ok try adding $p->of(false); before adding the image. You've included output formatting off above when creating the page, but then the page is saved which automatically turns it on again.
    1 point
  14. I doubt Tracy is the problem, but to disable Tracy you can rename it to .TracyDebugger. Just FTP into the server and rename the folder in site>modules>.TracyDebugger Hope that helps
    1 point
  15. Hi all, I'd like to give some feedback about the solution I ended up with. To bundle a few extra fields together with each image, instead of using a repeater I used the module ImagesExtra by @justb3a: https://github.com/justb3a/processwire-imageextra I created an ImageExtra field named imagex and added the following fields: startrow, startcol, widthcols, zindex They refer to a grid of rows and columns, each 2rem high and 2rem wide. startrow and startcol are the topmost row and the leftmost column covered by the image; widthcols is the width of the image, given as count of columns. zindex is the value of the usual z-index attribute to control which image is on top of the stack (in case of overlapping images). The picture below shows an image in the grid with the values startrow=2, startcol=4, widthcols=6 and zindex=1. The CSS grid is defined as follows: .wrapper { display: grid; grid-template-rows: repeat(60, [row] 2rem); grid-template-columns: repeat(40, [col] 2rem); grid-gap: 0; width: 80%; margin: 0 auto; padding: 0; } .wrapper div { width: 2rem; height: 2rem; } The CSS definitions for the images are embedded in the HTML code using a style element, allowing the use of php variables. (Note that the value of widthcols is used to calculate the width of the image in the unit rem, stored in the variable $wrem. The height is calculated automatically, keeping the aspect ratio.) The images together with the extra field values are stored in the field $imagex, and in the foreach loop for each of them the class definition is built: <section class="wrapper"> <?php if ($imagex) { $i = 0; foreach ($imagex as $pic){ $i++; $sr = $pic->startrow; $sc = $pic->startcol; $w = $pic->widthcols; $wrem = 2*$w . 'rem'; $zi = $pic->zindex; echo " <style> .no$i { grid-row: row $sr; grid-column: col $sc; } .no$i > img { width: $wrem; z-index: $zi; } </style> "; echo "\n<div class=no$i>\n"; echo "<img src=$pic->url alt='$pic->description' />"; echo "\n</div>\n"; } }; ?> </section> Works like a charm. Thanks again for all your hints and proposals!
    1 point
  16. @kkalgidim Not sure that it would suit your case, but worth to mention that there is the 'owner' selector, so you can use it instead of updating field. https://processwire.com/blog/posts/processwire-3.0.95-core-updates/
    1 point
  17. The easiest I could think of is to export your models into CSVs using this exporter app or by code with this library, and then upload them using ProcessWire's CSV import module. It would require some planning on how you would map your existing data into ProcessWire tree, and its field/template/page paradigm, but it shouldn't be too hard once you've figured that out.
    1 point
×
×
  • Create New...