Jump to content

Peter Knight

Members
  • Posts

    1,466
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by Peter Knight

  1. Thanks apesia. So simple! Now that I know where to look, I notice that here is a $user->name property. Can't I do this? if ($user->name("Peter")) { echo "Hidden content"; } or refer to a user by pageID if ($user->id("41")) { echo "Hidden content"; } I'm not at my installation right now.
  2. Hi guys I'm attempting to do something new (to me) in PW and a search is coming up blank. I suspect I'm using the wrong search terms. I'd like to create a simple content block that is only shown to distinct PW users. The overall page itself would be public and viewable by anyone but there's a particular DIV which only shows to PW user X or Y. Can someone point me in the right direction? I thought this would be session based but having searched the forums and Google I'm coming up with results on hiding back-end content etc instead of front in within public pages. Cheers P
  3. Click the little icon above the top right of your last image. Looks like a list icon. Once the images are displayed in a list you should see a recycle bin icon.
  4. Can I suggest a Bulk Actions mechanism for comments which I think is really useful. I relaunched a new ProcessWire website yesterday and we had approx 350 comments overnight. Client has been asking if he can bulk manage them as his previous CMS allowed this.
  5. The trash link is only visible for super users. Agree it'd be helpful to have option to display for other roles.
  6. Ok I got it to work. I realised I had to zap the contents of both 'item_tpl' and item_current_tpl' My final working code is as follows. Apologies if I'm filling up this thread with my own hacked code and examples. Just hoping it's useful to someone in the future. <?php $nav = $modules->get("MarkupSimpleNavigation"); function myItemString(HookEvent $event){ $child = $event->arguments('page'); // current rendered child page // any logic with $child possible here $myimage = $child->nav_icon; // set the return value of this hook to a custom string $event->return .= "<div class='nav-icon'><img src='{$myimage->url}'></div><a href='$child->url'>$child->title</a>"; } $options = array( 'parent_class' => 'parents', 'current_class' => 'current', 'has_children_class' => 'has_children', 'levels' => true, 'levels_prefix' => 'level-', 'max_levels' => 1, 'firstlast' => true, 'collapsed' => false, 'show_root' => true, 'selector' => '', 'selector_field' => 'nav_selector', 'outer_tpl' => '<ul class="sidelist">||</ul>', 'inner_tpl' => '<ul>||</ul>', 'list_tpl' => '<li%s >||</li>', 'list_field_class' => '', 'item_tpl' => '', 'item_current_tpl' => '', 'xtemplates' => '', 'xitem_tpl' => '<a href="{url}">{title}</a>', 'xitem_current_tpl' => '<span>{title}</span>', 'date_format' => 'Y/m/d', 'code_formatting' => false, 'debug' => false ); $root = $page->rootParent; // Start from the top root parent of current page // setup the hook after on ___getItemString($class, $page) method $nav->addHookAfter('getItemString', null, 'myItemString'); echo $nav->render($options, null, $root); ?>
  7. Macrura and Soma - you're both correct. My code only works for the current page. I hadn't realised earlier as I was testing and viewing a single page which just happened to be my current page :-/ Moving on, I've worked Somas example into my template, updated the field names etc to produce the following. As Soma mentioned, this displays an icon only for the current page. <?php $nav = $modules->get("MarkupSimpleNavigation"); function myItemString(HookEvent $event){ // the current rendered child page $child = $event->arguments('page'); // if current child you're viewing if($child === wire("page")) { $myimage = $child->nav_icon; $itemMarkup = "<div class='nav-icon'><img src='{$myimage->url}'></div><a href='{$child->url}'>{$child->title}</a>"; $event->return .= $itemMarkup; // send back the markup that will present a item } } // setup the hook $nav->addHookAfter('getItemString', null, 'myItemString'); // the navigation options $options = array( 'parent_class' => 'parents', 'current_class' => 'current', 'has_children_class' => 'has_children', 'levels' => true, 'levels_prefix' => 'level-', 'max_levels' => 1, 'firstlast' => true, 'collapsed' => false, 'show_root' => true, 'selector' => '', 'selector_field' => 'nav_selector', 'outer_tpl' => '<ul class="sidelist">||</ul>', 'inner_tpl' => '<ul>||</ul>', 'list_tpl' => '<li%s >||</li>', 'list_field_class' => '', 'item_tpl' => '<a href="{url}">{title}</a>', 'item_current_tpl' => '<a href="{url}">{title}</a>', 'xtemplates' => '', 'xitem_tpl' => '<a href="{url}">{title}</a>', 'xitem_current_tpl' => '<span>{title}</span>', 'date_format' => 'Y/m/d', 'code_formatting' => false, 'debug' => false ); $root = $page->rootParent; // Start from the top root parent of current page // a render will then also trigger the hook above on each item echo $nav->render($options, null, $root); ?> The key to getting my menu to produce a unique icon per page seemed to be removing the if($child === wire("page")) function myItemString(HookEvent $event){ // the current rendered child page $child = $event->arguments('page'); $myimage = $child->nav_icon; $itemMarkup = "<div class='nav-icon'><img src='{$myimage->url}'></div><a href='{$child->url}'>{$child->title}</a>"; $event->return .= $itemMarkup; // send back the markup that will present a item } My only problem at the moment is that each navigation link is being output twice.
  8. Each pages navigation link has an icon.
  9. Eventually solved this with the help of a mate who is an experienced PHP developer. <?php $treeMenu = $modules->get("MarkupSimpleNavigation"); $myimage = $page->images->getTag('icon')->width(50)->url; $options = array( 'item_current_tpl' => '<div class="nav-icon"><img src="'.$myimage.'"></div><a href="{url}">{title}</a>', ; ?> We both acknowledge that a better solution is most likely to use the Hook method outlined in the Module readme but I needed something quick (approaching deadline) that I could relate to and maintain myself. Given time I may look more closely at the Hook method and try understand that a bit more.
  10. Wondered if I was along the right track with following. I associate a variable with my image tag including width: $myimage = $page->images->getTag('icon')->width(300)->url; and then in the MarkupSimpleNavigation refer to $myimage in the item_crrent_tpl line 'item_current_tpl' => ' <div class="nav-icon"><img src="{myimage}"></div><a href="{url}">{title}</a> ',
  11. Marek - i like your demos. Very nice work. Have you seen http://mmenu.frebsite.nl/ as a lightweight jQuery approach?
  12. @soma I was trying to add an image to the left of each navigation link. As your docs mention, the following will grab the first image in a field I specify 'item_current_tpl' => '<div class="nav-icon"><img src="{images}"></div><a href="{url}">{title}</a>', I had a few challenges here and wondered about best approach Image Tag My images field may contain several images. I could create a separate navigation_images field but would love to call an image by tag Image size I can accomplish by CSS but wondered if I could apply the API width() Ultimately, my markup would resemble something like this. It's the getTag and width(300) which break the call 'item_current_tpl' => '<div class="nav-icon"><img src="{images->getTag('icon')->width(300)->url}"></div><a href="{url}">{title}</a>',
  13. Thanks for clarifying @LostKobrakai Something I'd been meaning to ask for a while.
  14. I noticed some example code provided recently had a very simple API format as follows: <a href='{url}'>{title}</a> Since I started using PW I've always preceded my field name with a variable and thought this was best practice. <a href='{$item->url}'>{$item->title}</a> What's the general advice here? Looking at the forums and blog I can see mention of a shorter syntax mentioned here https://processwire.com/blog/posts/processwires-roadmap-in-2015/ But then I can also see a post which seems to indicate that short tag-like syntax isn't necessarily a good thing https://processwire.com/api/why-php-syntax/ Edit: changed "proceeded" to "preceded"
  15. Thanks. I was almost there. I can see where I went wrong with the second example too.
  16. I really like the simpler markup here and I'm using it to echo a series of blog categories separate by a , <?php $page->blog_category->implode(", ", "title"); ?> Im unsure though how to wrap the title in a link. I'm thinking I first need to create a variable called $cats and associate it with my blog_category field. I then need to place an anchor before the title. <?php $cats = $page->blog_category; echo $page->blog_category->implode(", ", "<a href=\"$cats->url\">title</a>"); ?> As this produces no output and no error, I'm clearly doing something wrong. Looking at Ryans example of the new API, I can modify an example to include the url <?php $cats = $page->blog_category; echo $cats->implode(function($cat) { return "<a href='$cat->url'>$cat->title</a>"; }); ?> I know I'm close! Any help much appreciated.
  17. After using both Bootstrap and Foundation for the past 2 -ish years, here's a list of stuff I wish I'd known "back then". Bootstrap comes with a nicer default styling. It shouldn't really matter as the point here is to put your branding on the top. Foundations default aesthetic isn't as pretty IMHO and I have to do more work on top of a Foundation install. Foundation doesn't have an x-small grid and starts at Small. Bootstrap on the other hand does have a =n x-small grid and I miss this when working with Foundation Foundation has slightly less code in setting up a row/column layout. Bootstrap has an extra Container class that each row everything needs to be wrapped in Both are pretty heavy in JS. Dont call all the JS. Just call the JS for the components you need That's pretty much it for me, I settled on Foundation but miss Bootstrap and am thinking of reverting or trying something much lighter. Heard good things about http://getskeleton.com/
  18. Hey Mike Nice Module. I've been using Redirects for a project and as mentioned I have 500 redirects to make. Actually, 400 left with 100 done. I might port to JL as I like the wildcard integration. Can I make a suggestion now that I've installed it? 1 The Destination column IMHO would be best displaying the new path and not the page title. Displaying the page title (to me) largely tells me nothing useful. 2 Minor point but the font sizes are different than the rest of the RenoTheme fonts. Not a biggie but when everything in Reno is so consistent it'd be nice to continue that. I appreciate you've 2 extra date columns and that could be reason for reducing font size. Otherwise, nice job. The 404 Monitor is great
  19. My original comment referred to the Redirects Module though? Didn't realise there was a Jumplinks conversation here too.
  20. They satisfy different use cases. If I don't know my page name but know where it's stored I will use the tree. Sometimes page names have changed. Likewise, in reverse... If I know the page name but not where it's located in the tree an auto complete field solves that And even if I know where a page is located in the tree, on large trees manually locating 500 pages takes a long time.
  21. When you're Selecting a page to redirect to you're presented with the site tree. I'd love to see an additional auto-complete field here too. We have about 500 individual redirects to implement and it would drastically reduce our time. Is it on the roadmap or could it be?
  22. Would this help? http://modules.processwire.com/modules/image-extra/
  23. I have a homepage with a Page field which allows client to choose a single page. <?php foreach ($page->feat_home_pptv as $pptv) { echo"test" ;} ?> This echoes 22 "test" on the page even though the Page field is limited to a single Page Ok, I thought. Lets try this with some real content ... <?php foreach ($page->feat_home_pptv as $pptv) { echo"{$pptv->title}" ;} ?> The above produces produces an odd looking error referencing a CommentArray Error: Exception: Class 'CommentArray' doesn't yet implement method 'makeBlankItem()' and it needs to. (in /var/www/vhosts/domain.com/httpdocs/wire/core/WireArray.php line 131) #0 /var/www/vhosts/domain.com/httpdocs/wire/core/WireArray.php(1457): WireArray->makeBlankItem() #1 /var/www/vhosts/domain.com/httpdocs/wire/core/WireArray.php(443): WireArray->usesNumericKeys() #2 /var/www/vhosts/domain.com/httpdocs/wire/core/WireArray.php(464): WireArray->get('title') #3 /var/www/vhosts/domain.com/httpdocs/site/templates/home.php(88): WireArray->__get('title') #4 /var/www/vhosts/domain.com/httpdocs/wire/core/TemplateFile.php(182): require('/var/www/vhosts...') #5 [internal function]: TemplateFile->___render() #6 /var/www/vhosts/domain.com/httpdocs/wire/core/Wire.php(397): call_user_func_array(Array, Array) #7 /var/www/vhosts/domain.com/httpdocs/wire/core/Wire.php(332): Wire->runHooks('render', Array) #8 /var/www/vhosts/domain.com/httpdocs/wire This error message was shown because you are logged in as a Superuser. Error has been logged. The selected page's template doesn't have any comments markup html but it did have a comment field assigned to the template. I removed the comments field from the template and the selector produces no content <?php foreach ($page->feat_home_pptv as $pptv) { echo"{$pptv->title}" ;} ?> I'm running ProcessWire 2.6.14, MYSQL 5.5.41 Adding find('limit=1') works and produces no errors <?php foreach ($page->feat_home_pptv->find('limit=1') as $pptv) { echo"{$pptv->title}";} ?> I'm not sure why it needs that find('limit=1') as the field itself is set to only allow a single page
  24. I thought I needed to specify a template the content was based on or at least kick off with a selector. Thanks for the input.
  25. Hi Soma Just tried the Pollino module and it's fab. I'm not very familiar with the delayed output method you recommend here // may needs modification as this examples uses delayed output // but you get the idea $content .= "<div class='pollino_poll'>"; $content .= "<div class='inner'>"; $content .= "<h3>$page->title</h3>"; $content .= $modules->Pollino->renderPoll($page); $content .= "</div>"; $content .= "</div>"; To get it to output anything, I needed to tweak as follows. That's the recommened way, right? <?php $page->children; { $content .= "<div class='pollino_poll'>"; $content .= "<div class='inner'>"; $content .= "<h3>$page->title</h3>"; $content .= $modules->Pollino->renderPoll($page); $content .= "</div>"; $content .= "</div>"; } echo $content; ?>
×
×
  • Create New...