rafaoski Posted July 19, 2019 Share Posted July 19, 2019 (edited) This is a profile based on the Uikit3 framework and features from the regular site profile.Requires the latest version processwire 3.0.127 Download from this link:https://github.com/rafaoski/site-uk3-minimalLive Example: https://uk3-min.templatek.pl/Basic Info: Most of the profile settings and translates are in the _init.php file. Functions can be found in the _func.php, _uikit.php file. The entire view is rendered in the _main.php file that uses markup regions. You can easily add hooks using the ready.php file. Options page added with the new “Unique” status, which you can use in this simple way like:pages('options')->site_namepages->get('options')->site_name The Author's website's blog entries use URL segments (/ authors / {author-name} /), see views/blog/blog.php for more info. This profile has additional functions (_uikit.php) from the regular uikit3 profile, which is located in the basic ProcessWire installer ( there are minor changes, such as adding translations from _init.php ) Screnshoots: Edited October 2, 2019 by rafaoski Change the link to page view 7 Link to comment Share on other sites More sharing options...
dragan Posted July 19, 2019 Share Posted July 19, 2019 Nice. Apparently, my anti-virus software thinks your demo site is spam. 1 Link to comment Share on other sites More sharing options...
rafaoski Posted July 19, 2019 Author Share Posted July 19, 2019 (edited) Thanks for info @dragan ... This is just the test domain that I got along with the hosting ... Apparently something is wrong with her ... I've added a profile to a different domain https://uk3-min.templatek.pl/ ... Now it should be better ? Edited October 12, 2019 by rafaoski Update demo profile URL Link to comment Share on other sites More sharing options...
OrganizedFellow Posted September 21, 2019 Share Posted September 21, 2019 On 7/19/2019 at 11:10 AM, rafaoski said: Thanks for info @dragan ... This is just the test domain that I got along with the hosting ... Apparently something is wrong with her ... I've added a profile to a different domain https://proc-profiles.tk/uk3-min/ ... Now it should be better ? That leads to a 404 ? Anyone else try this neat profile? Link to comment Share on other sites More sharing options...
netcarver Posted October 1, 2019 Share Posted October 1, 2019 Hi @rafaoski, thank you for the profile. The demo seems to be unavailable via the link above, would you be able to bring it back to life? 1 Link to comment Share on other sites More sharing options...
rafaoski Posted October 2, 2019 Author Share Posted October 2, 2019 I have just changed the link to the page demo view ... 1 Link to comment Share on other sites More sharing options...
MateThemes Posted October 12, 2019 Share Posted October 12, 2019 Hello! First: Thank you for this great profile!!! I have a question: where can I turn of comments displayed on the blog post page? I cannot find it in the _func.php! Thank you very much! 1 Link to comment Share on other sites More sharing options...
rafaoski Posted October 12, 2019 Author Share Posted October 12, 2019 Hi and thanks @MateThemes ... The _init.php file is responsible for most profile settings ... You can change the setting blog comments options on this line:https://github.com/rafaoski/site-uk3-minimal/blob/9ea54af1f144fbb9642baee67adb604be0f4b1ea/templates/_init.php#L33'comments' => true, // Blog Comments Just change to false:'comments' => false, // Blog Comments This setting should disable comments in the files: templates/views/blog/blog-post.php ( https://github.com/rafaoski/site-uk3-minimal/blob/9ea54af1f144fbb9642baee67adb604be0f4b1ea/templates/views/blog/blog-post.php#L39 ) templates/views/blog/parts/_blog-article.php ( https://github.com/rafaoski/site-uk3-minimal/blob/9ea54af1f144fbb9642baee67adb604be0f4b1ea/templates/views/blog/parts/_blog-article.php#L59 ) You will learn more about the new functions API setting() from this place:https://processwire.com/blog/posts/processwire-3.0.119-and-new-site-updates/#new-functions-api-setting-function Link to comment Share on other sites More sharing options...
JheymanMejia Posted October 17, 2019 Share Posted October 17, 2019 Thank you very much for sharing, I have been trying to implement the option of "replying" in the comments for several weeks, I am quite close with the help provided by a user from this community. Do you know if this option is available for this uiKIT profile? 1 Link to comment Share on other sites More sharing options...
rafaoski Posted October 22, 2019 Author Share Posted October 22, 2019 Thank @JheymanMejia for the comment and I am sorry that I reply so late, but now I have a lot of work at home (renovation of the apartment). If you still need this option, I've added a simple reply button for comments and basic navigation for them. https://github.com/rafaoski/site-uk3-minimal/commit/bf4b437319f804a0bfcb1ef9000dad056d2a1cb6 If you want more or less nesting, you must set "Reply depth" in the setting comments field ( this will add a reply button ) Below is the code for the Regular blog site profile that should work: 1. Replace the selected functions in the file _uikit.php:https://github.com/processwire/processwire/blob/7d4ca45673152436ea492b6577341ee3550e2821/site-regular/templates/_uikit.php#L898-L1040 To this code: /***************************************************************************************** * ProcessWire/Uikit functions for rendering comments and comment forms * * Note: comment threads (depth), stars and votes are not yet supported in here. * */ /** * Render a comment repply * * @param int $commentId get comment id to add reply button * */ function commentReply($commentId) { return "<a class='CommentActionReply uk-button uk-button-text' data-comment-id='$commentId' href='#Comment$commentId'>Reply</a>"; } /** * Render a ProcessWire comment using Uikit markup * * @param Comment $comment * @param int $calculateDepth calculate comment depth * @return string * */ function ukComment(Comment $comment, $calculateDepth) { $text = $comment->getFormatted('text'); $cite = $comment->getFormatted('cite'); $website = $comment->getFormatted('website'); $field = $comment->getField(); $page = $comment->getPage(); $classes = array(); $metas = array(); $gravatar = ''; // Set reply button $maxDepth = $comment->getField()->depth; // Max depth from field comments $replies = $calculateDepth <= $maxDepth ? commentReply($comment->id) : ''; if($field->get('useGravatar')) { $img = $comment->gravatar($field->get('useGravatar'), $field->get('useGravatarImageset')); if($img) $gravatar = "<div class='uk-width-auto'><img class='uk-comment-avatar' src='$img' alt='$cite'></div>"; } if($website) $cite = "<a href='$website' rel='nofollow' target='_blank'>$cite</a>"; $created = wireDate('relative', $comment->created); if($field->get('usePermalink')) { $permalink = $page->httpUrl; $urlSegmentStr = $this->wire('input')->urlSegmentStr; if($urlSegmentStr) $permalink .= rtrim($permalink, '/') . $urlSegmentStr . '/'; $permalink .= '#Comment' . $comment->id; $permalink = "<a href='$permalink'>" . __('Permalink') . "</a>"; $metas[] = "<li>$permalink</li>"; } $classes = implode(' ', $classes); $metas = implode('', $metas); $out = " <article id='Comment$comment->id' class='$classes uk-comment uk-comment-primary' data-comment='$comment->id'> <header class='uk-comment-header uk-grid-medium uk-flex-middle' uk-grid> $gravatar <div class='uk-width-expand'> <h4 class='uk-comment-title uk-margin-remove'>$cite</h4> <ul class='uk-comment-meta uk-subnav uk-subnav-divider uk-margin-remove-top'> <li>$created</li> $metas </ul> </div> </header> <div class='uk-comment-body'> $text </div> $replies </article> "; return $out; } /** * Render a list of ProcessWire comments using Uikit markup * * Note: does not currently support threaded comments (comment depth). * Use ProcessWire’s built-in comments rendering for that purpose. * * @param CommentArray $comments * @param array|string $options Options to modify default behavior * - `id` (string): HTML id attribute of the comments list (default='comments'). * @param int $calculateDepth calculate comment depth * @return string * */ function ukComments(CommentArray $comments, $options = array(), $calculateDepth = 0) { $out = ''; $calculateDepth++; $defaults = array( 'id' => 'comments', 'ul' => true ); if(!count($comments)) return ''; $options = _ukMergeOptions($defaults, $options); if($options['ul']) $out .= "<ul id='$options[id]' class='uk-comment-list'>"; foreach($comments as $comment) { $out .= "<li class='uk-margin-small'>"; $out .= ukComment($comment, $calculateDepth); // check comment children if($comment->children) { $out .= "<ul class='uk-nav-sub uk-margin-remove'>"; $out .= ukComments($comment->children, ['ul' => false], $calculateDepth); $out .= '</ul>'; } $out .= "</li>"; } if($options['ul']) $out .= "</ul>"; return $out; } /** * Render a comment posting form * * @param CommentArray $comments * @param array $options See `CommentForm` class for all options. * @return string * */ function ukCommentForm(CommentArray $comments, array $options = array()) { $defaults = array( 'headline' => "", 'successMessage' => __('Thank you, your comment has been posted.'), 'pendingMessage' => __('Your comment has been submitted and will appear once approved by the moderator.'), 'errorMessage' => __('Your comment was not saved due to one or more errors.') . ' ' . __('Please check that you have completed all fields before submitting again.'), ); $options = _ukMergeOptions($defaults, $options); $options['successMessage'] = ukAlertSuccess($options['successMessage'], 'check'); $options['pendingMessage'] = ukAlertSuccess($options['pendingMessage'], 'check'); $options['errorMessage'] = ukAlertDanger($options['errorMessage'], 'warning'); if(!isset($options['attrs']) || !isset($options['attrs']['class'])) { $options['attrs'] = array('class' => 'uk-comment uk-comment-primary'); } $adjustments = array( "<input type='text'" => "<input type='text' class='uk-input'", "<input type='email'" => "<input type='email' class='uk-input'", "<p class='CommentForm" => "<p class='uk-margin-remove-top CommentForm", "<textarea " => "<textarea class='uk-textarea' ", "<button " => "<button class='uk-button uk-button-primary' ", "<label " => "<label class='uk-form-label' ", ); $out = $comments->renderForm($options); $out = str_replace(array_keys($adjustments), array_values($adjustments), $out); return $out; } 2. Change lines from 14 to 25 inside blog-post.php:https://github.com/processwire/processwire/blob/7d4ca45673152436ea492b6577341ee3550e2821/site-regular/templates/blog-post.php#L14-L25 To this code: // https://processwire.com/talk/topic/594-how-can-i-use-pagination-with-comments/ $limit = 12; $start = ($input->pageNum - 1) * $limit; // Find comments that don't have a parent ( parent_id=0 ) $comments = page()->comments->find("start=$start, limit=$limit, parent_id=0"); // comment list if(count($comments)) { echo ukHeading3("Comments", "icon=comments"); echo ukComments($comments); if($input->pageNum > 1) { echo "<a class='uk-button uk-button-text' href='./page" . (input()->pageNum - 1) . "'>" . ukIcon('arrow-left') . __('Previous Comments') . "</a> "; } // Find comments that don't have a parent ( parent_id=0 ) if($start + $limit < count(page()->comments->find("parent_id=0"))) { echo "<a class='uk-button uk-button-text' href='./page" . (input()->pageNum + 1) . "'>" . __('Next Comments') . ukIcon('arrow-right') . "</a>"; } } // comment form echo ukHeading3("Post a comment", "icon=comment"); echo ukCommentForm(page()->comments); Remember to set the Reply depth inside comments field: And adding options for page nubmers in the setting blog-post template: Link to comment Share on other sites More sharing options...
JheymanMejia Posted October 23, 2019 Share Posted October 23, 2019 18 hours ago, rafaoski said: Thank @JheymanMejia for the comment and I am sorry that I reply so late, but now I have a lot of work at home (renovation of the apartment). If you still need this option, I've added a simple reply button for comments and basic navigation for them. https://github.com/rafaoski/site-uk3-minimal/commit/bf4b437319f804a0bfcb1ef9000dad056d2a1cb6 If you want more or less nesting, you must set "Reply depth" in the setting comments field ( this will add a reply button ) Below is the code for the Regular blog site profile that should work: 1. Replace the selected functions in the file _uikit.php:https://github.com/processwire/processwire/blob/7d4ca45673152436ea492b6577341ee3550e2821/site-regular/templates/_uikit.php#L898-L1040 To this code: /***************************************************************************************** * ProcessWire/Uikit functions for rendering comments and comment forms * * Note: comment threads (depth), stars and votes are not yet supported in here. * */ /** * Render a comment repply * * @param int $commentId get comment id to add reply button * */ function commentReply($commentId) { return "<a class='CommentActionReply uk-button uk-button-text' data-comment-id='$commentId' href='#Comment$commentId'>Reply</a>"; } /** * Render a ProcessWire comment using Uikit markup * * @param Comment $comment * @param int $calculateDepth calculate comment depth * @return string * */ function ukComment(Comment $comment, $calculateDepth) { $text = $comment->getFormatted('text'); $cite = $comment->getFormatted('cite'); $website = $comment->getFormatted('website'); $field = $comment->getField(); $page = $comment->getPage(); $classes = array(); $metas = array(); $gravatar = ''; // Set reply button $maxDepth = $comment->getField()->depth; // Max depth from field comments $replies = $calculateDepth <= $maxDepth ? commentReply($comment->id) : ''; if($field->get('useGravatar')) { $img = $comment->gravatar($field->get('useGravatar'), $field->get('useGravatarImageset')); if($img) $gravatar = "<div class='uk-width-auto'><img class='uk-comment-avatar' src='$img' alt='$cite'></div>"; } if($website) $cite = "<a href='$website' rel='nofollow' target='_blank'>$cite</a>"; $created = wireDate('relative', $comment->created); if($field->get('usePermalink')) { $permalink = $page->httpUrl; $urlSegmentStr = $this->wire('input')->urlSegmentStr; if($urlSegmentStr) $permalink .= rtrim($permalink, '/') . $urlSegmentStr . '/'; $permalink .= '#Comment' . $comment->id; $permalink = "<a href='$permalink'>" . __('Permalink') . "</a>"; $metas[] = "<li>$permalink</li>"; } $classes = implode(' ', $classes); $metas = implode('', $metas); $out = " <article id='Comment$comment->id' class='$classes uk-comment uk-comment-primary' data-comment='$comment->id'> <header class='uk-comment-header uk-grid-medium uk-flex-middle' uk-grid> $gravatar <div class='uk-width-expand'> <h4 class='uk-comment-title uk-margin-remove'>$cite</h4> <ul class='uk-comment-meta uk-subnav uk-subnav-divider uk-margin-remove-top'> <li>$created</li> $metas </ul> </div> </header> <div class='uk-comment-body'> $text </div> $replies </article> "; return $out; } /** * Render a list of ProcessWire comments using Uikit markup * * Note: does not currently support threaded comments (comment depth). * Use ProcessWire’s built-in comments rendering for that purpose. * * @param CommentArray $comments * @param array|string $options Options to modify default behavior * - `id` (string): HTML id attribute of the comments list (default='comments'). * @param int $calculateDepth calculate comment depth * @return string * */ function ukComments(CommentArray $comments, $options = array(), $calculateDepth = 0) { $out = ''; $calculateDepth++; $defaults = array( 'id' => 'comments', 'ul' => true ); if(!count($comments)) return ''; $options = _ukMergeOptions($defaults, $options); if($options['ul']) $out .= "<ul id='$options[id]' class='uk-comment-list'>"; foreach($comments as $comment) { $out .= "<li class='uk-margin-small'>"; $out .= ukComment($comment, $calculateDepth); // check comment children if($comment->children) { $out .= "<ul class='uk-nav-sub uk-margin-remove'>"; $out .= ukComments($comment->children, ['ul' => false], $calculateDepth); $out .= '</ul>'; } $out .= "</li>"; } if($options['ul']) $out .= "</ul>"; return $out; } /** * Render a comment posting form * * @param CommentArray $comments * @param array $options See `CommentForm` class for all options. * @return string * */ function ukCommentForm(CommentArray $comments, array $options = array()) { $defaults = array( 'headline' => "", 'successMessage' => __('Thank you, your comment has been posted.'), 'pendingMessage' => __('Your comment has been submitted and will appear once approved by the moderator.'), 'errorMessage' => __('Your comment was not saved due to one or more errors.') . ' ' . __('Please check that you have completed all fields before submitting again.'), ); $options = _ukMergeOptions($defaults, $options); $options['successMessage'] = ukAlertSuccess($options['successMessage'], 'check'); $options['pendingMessage'] = ukAlertSuccess($options['pendingMessage'], 'check'); $options['errorMessage'] = ukAlertDanger($options['errorMessage'], 'warning'); if(!isset($options['attrs']) || !isset($options['attrs']['class'])) { $options['attrs'] = array('class' => 'uk-comment uk-comment-primary'); } $adjustments = array( "<input type='text'" => "<input type='text' class='uk-input'", "<input type='email'" => "<input type='email' class='uk-input'", "<p class='CommentForm" => "<p class='uk-margin-remove-top CommentForm", "<textarea " => "<textarea class='uk-textarea' ", "<button " => "<button class='uk-button uk-button-primary' ", "<label " => "<label class='uk-form-label' ", ); $out = $comments->renderForm($options); $out = str_replace(array_keys($adjustments), array_values($adjustments), $out); return $out; } 2. Change lines from 14 to 25 inside blog-post.php:https://github.com/processwire/processwire/blob/7d4ca45673152436ea492b6577341ee3550e2821/site-regular/templates/blog-post.php#L14-L25 To this code: // https://processwire.com/talk/topic/594-how-can-i-use-pagination-with-comments/ $limit = 12; $start = ($input->pageNum - 1) * $limit; // Find comments that don't have a parent ( parent_id=0 ) $comments = page()->comments->find("start=$start, limit=$limit, parent_id=0"); // comment list if(count($comments)) { echo ukHeading3("Comments", "icon=comments"); echo ukComments($comments); if($input->pageNum > 1) { echo "<a class='uk-button uk-button-text' href='./page" . (input()->pageNum - 1) . "'>" . ukIcon('arrow-left') . __('Previous Comments') . "</a> "; } // Find comments that don't have a parent ( parent_id=0 ) if($start + $limit < count(page()->comments->find("parent_id=0"))) { echo "<a class='uk-button uk-button-text' href='./page" . (input()->pageNum + 1) . "'>" . __('Next Comments') . ukIcon('arrow-right') . "</a>"; } } // comment form echo ukHeading3("Post a comment", "icon=comment"); echo ukCommentForm(page()->comments); Remember to set the Reply depth inside comments field: And adding options for page nubmers in the setting blog-post template: Hello, thanks for the information, I see it very complete. With the help of @MilenKo i can moved forward a bit, I will also review what you share and I will tell you how it goes later. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now