Jump to content

rafaoski

Members
  • Posts

    81
  • Joined

  • Last visited

  • Days Won

    2

rafaoski last won the day on March 9 2018

rafaoski had the most liked content!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

rafaoski's Achievements

Full Member

Full Member (4/6)

147

Reputation

  1. It would be great to have something like tinaCms for editing pages ...
  2. I don't know if I understood correctly, but it looks like you can also use $files->include() or $files->render() methods in your _main.php file. A simple example from the Regular Uikit 3 profile, which we will include the _header.php inside file _main.php with some variables: <?php namespace ProcessWire; // _main.php template file, called after a page’s template file $home = pages()->get('/'); // homepage $siteTitle = 'Regular'; $siteTagline = $home->summary; // as a convenience, set location of our 3rd party resources (Uikit and jQuery)... urls()->set('uikit', 'wire/modules/AdminTheme/AdminThemeUikit/uikit/dist/'); urls()->set('jquery', 'wire/modules/Jquery/JqueryCore/JqueryCore.js'); // ...or if you prefer to use CDN hosted resources, use these instead: // urls()->set('uikit', 'https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-beta.40/'); // urls()->set('jquery', 'https://code.jquery.com/jquery-2.2.4.min.js'); ?> <!-- HEADER --> <?php $files->include('_header', ['home' => $home, 'siteTitle' => $siteTitle, 'siteTagline' => $siteTagline]); // echo $files->render('_header', ['home' => $home, 'siteTitle' => $siteTitle, 'siteTagline' => $siteTagline]); ?> _header.php: <?php namespace ProcessWire; // _header.php file ?> <!DOCTYPE html> <html lang='en'> <head id='html-head'> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title id='html-title'><?=page()->title?></title> <meta name="description" content="<?=page()->summary?>"> <link rel="stylesheet" href="<?=urls()->uikit?>css/uikit.min.css" /> <link rel="stylesheet" href="<?=urls()->templates?>styles/main.css"> <script src="<?=urls()->jquery?>"></script> <script src="<?=urls()->uikit?>js/uikit.min.js"></script> <script src="<?=urls()->uikit?>js/uikit-icons.min.js"></script> </head> <body id='html-body'> <!-- MASTHEAD --> <header class='uk-background-muted'> <div id='masthead' class="uk-container"> <h2 id='masthead-logo' class='uk-text-center uk-margin-medium-top uk-margin-small-bottom'> <a href='<?=urls()->root?>'> <img src='<?=urls()->templates?>styles/images/coffee4.svg' alt='coffee'><br /> </a> <?=$siteTitle?> </h2> <p id='masthead-tagline' class='uk-text-center uk-text-small uk-text-muted uk-margin-remove'> <?=$siteTagline?> </p> <nav id='masthead-navbar' class="uk-navbar-container" uk-navbar> <div class="uk-navbar-center uk-visible@m"> <?=ukNavbarNav($home->and($home->children), [ 'dropdown' => [ 'basic-page', 'categories' ] ])?> </div> </nav> </div> </header> It is also important to include <?php namespace ProcessWire; ?> in each of template files. Sometimes it also helps to enable $config->useFunctionsAPI in the config.php file ( Allow most API variables to be accessed as functions? ), this will be more useful in your custom functions, where for example you can call page()->title instead of $page->title, which will not work inside a your custom function if you do not enter any arguments, as in the example below: <?php function showTitle() { echo '<h1>' . page()->title . '</h1>'; // This work // echo $page->title; // This not work } // Show Title showTitle(); ?> The setting() helper function is a good addition to the _init.php file, to which I usually attach the most important page options, which are also available in custom functions without entering arguments such as the init.php file: <?php namespace ProcessWire; /** * * This _init.php file is called automatically by ProcessWire before every page render * * Get or set a runtime site setting * @link https://processwire.com/api/ref/functions/setting/ * */ /** @var ProcessWire $wire */ // set or replace multiple settings setting([ 'siteTitle' => 'ProcessWire CMS / CMF', 'siteDescription' => 'ProcessWire is like a power tool for your website, able to deliver any output, at any scale, to any number of people. ', ]); // Your custom functions that are better placed in the _func.php or _uikit.php file (this is just an example) function siteBranding() { echo "<h1>" . setting('siteTitle') . "</h1>"; echo "<h2>" . setting('siteDescription') . "</h2>"; } include_once('./_uikit.php'); Now you can display the function wherever you want: <?php siteBranding() ?> For example, in this Site Profile I have put site options or translations inside file _init.php: <?php namespace ProcessWire; /** * * This _init.php file is called automatically by ProcessWire before every page render * * Get or set a runtime site setting * @link https://processwire.com/api/ref/functions/setting/ * */ // as a convenience, set location of our 3rd party resources (jQuery)... urls()->set('jquery', 'https://code.jquery.com/jquery-3.4.1.min.js'); $home = pages('/'); $blog = pages()->get("template=blog"); $options = pages()->get('/options/'); // Basic Settings setting([ // Custom html classes 'htmlClasses' => WireArray([ 'template-' . page()->template->name, 'page-' . page()->id, ]), // Basic 'home' => $home, 'privacyPolicy' => pages()->get("template=privacy"), 'options' => $options, 'siteName' => $options->text, 'logo' => $options->logo, 'favicon' => $options->favicon, 'socialProfiles' =>$options->social_profiles, 'metaTitle' => page('meta_title|title'), 'metaDescription' => page()->meta_description, 'noindex' => false, 'poweredUrl' => 'https://processwire.com', // Home Sections 'hero' => $home, 'about' => pages()->get("template=about"), 'projects'=> pages()->get("template=projects"), 'recent' => $blog->child(), // Path to template parts 'homeParts' => 'parts/home', 'blogParts' => 'parts/blog', // Blog 'blog' => $blog, 'disableComments' => $options->more_options->get("name=disable-comments"), // Contact Page 'saveMessages' => $options->more_options->get("name=save-messages"), // Images 'img' => page()->images && page()->images->count() ? page()->images : '', // Main 'mainTitle' => page('title'), 'mainImage' => true, // Set basic background image for all pages // Bottom Panel 'bottomPanel' => $options->bottom_panel, // Basic Translations 'lang' => __('en'), 'edit' => __('Edit'), 'next' => __('Next'), 'previous' => __('Previous'), 'search' => __('Search'), 'search-site' => __('Search the entire site'), 'found-matches' => __('Found %d page(s)'), 'no-results' => __('Sorry, no results were found.'), 'maintenance-mode' => __('Maintenance Mode'), 'site-disabled' => __('Our site is currently disabled.'), 'to-top' => __('To top'), 'we-sociable' => __('We are sociable'), 'powered' => __('Probably supported by ProcessWire CMS'), // Contact Page Translate 'message-error' => __('Some errors, please update your form'), 'message-success' => __('Success, your message has been sent'), 'txt-from' => __('From'), 'form-legend' => __('Contact Us'), 'form-name' => __('Name'), 'form-email' => __('Email'), 'form-privacy' => __('I agree with the %s terms.'), 'form-message' => __('Message'), 'form-spam' => __('To help prevent automated spam, please answer this question'), 'fs-placeholder' => __('* Using only numbers, what is 10 plus 15?'), 'fs-error' => __('Fill out the spam prevention box correctly'), 'form-submit' => __('Submit'), // Blog Translate 'in-blog' => __('In the blog'), 'posted-in' => __('Posted in'), 'all-posts' => __('All posts'), 'recent-posts' => __('Recent posts'), 'read-more' => __('Read More'), 'written-on' => __('Written on'), 'byline-text' => __('Posted by %1$s on %2$s'), 'also-like' => __('You might also like:'), 'author' => __('Author'), 'authors' => __('Authors'), // is also url segments ( blog/authors/author-mame ) 'category' => __('Category'), 'tag' => __('Tag'), 'author-checkbox' => __('You probably need to check the author checkbox in your user profile'), 'rss' => __('RSS'), 'recent-entries' => __('Recent entries'), // Comments Form Translate 'previous-comments' => __('Previous Comments'), 'next-comments' => __('Next Comments'), 'post-comment' => __('Post a comment'), 'comment' => __('Comment'), 'comments' => __('Comments'), 'no-comments' => __('No Comments'), 'comments-closed' => __('Comments are closed'), 'comment-header' => __('Posted by {cite} on {created}'), 'success-message' => __('Thank you, your comment has been posted.'), 'pending-message' => __('Your comment has been submitted and will appear once approved by the moderator.'), 'error-message' => __('Your comment was not saved due to one or more errors.') . ' ' . __('Please check that you have completed all fields before submitting again.'), 'comment-cite' => __('Your Name'), 'comment-email' => __('Your E-Mail'), 'comment-website' => __('Website'), 'comment-stars' => __('Your Rating'), 'submit' => __('Submit'), 'stars-required' => __('Please select a star rating'), 'reply' => __('Reply') ]); include_once('./_func.php');
  3. Thanks for the update which seems to be a great addition ... Following the blog tutorial I have a some problems. First of all, I'm not sure (I only know the basics of php OOP), but the summary() method should look like this: return wire()->sanitizer->truncate($this->body, 300); instead return $this->sanitizer->truncate($this->body, 300); In general, I mean the byline() method which does not return the created user correctly, Tracy Debugger show me: PHP Notice: Trying to get property 'name' of non-object in ...\regular\site\classes\BlogPostPage.php:7 This is my code site/classes/BlogPostPage.php: <?php namespace ProcessWire; // classes/BlogPostPage.php class BlogPostPage extends Page { public function byline() { $date = wireDate('Y/m/d', $this->published); $name = $this->createdUser->name; return "Posted on $date by $name"; } public function summary() { return wire()->sanitizer->truncate($this->body, 300); } } This is home.php <?php foreach($pages->find('template=blog-post, sort=-published') as $post): ?> <div class='blog-post'> <h2><?=$post->title?></h2> <p class='byline'> <?=$post->byline()?> </p> <p> <?=$post->summary()?> <a href='<?=$post->url?>'>Read more</a> </p> </div> <?php endforeach; ?> All with the latest ProcessWire 3.0.152 dev and Regular UIKIT profile Can anyone confirm the issue or what I am doing wrong?
  4. I recommend the modern CodyFrame framework, and the main reason is that it has separate elements, i.e. you add to the page what you need as Components, so there is no mess in the code, and the page should load faster, the size of the files will not be huge, yes as in most major CSS frameworks. There are also other reasons, such as the Global Editor ( GLOBALS ), thanks to which your website will not look like hundreds of others based on the same CSS frameworks (you can customize many elements such as colors, typography, buttons, forms ). Plus many basic Tutorials that you can start with. You can also see this Site Profile, which can be a good start to familiarize yourself with this framework.
  5. 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:
  6. 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
  7. The easiest way is to set the options page in the _init.php file: $siteOptions = $pages->get('/options/'); // If you set setFunctionsAPI ( $config->useFunctionsAPI = true; ) to true in the configuration file, you can display them in the template in this way $siteOptions = pages()->get('/options/'); //or $siteOptions = pages('/options/'); Then in the template just display the fields: <h1><?= $siteOptions->site_name ?></h1> <?php // In the field settings you should select to display a single image if ($siteOptions->logo): ?> <img src="<?= $siteOptions->logo->url ?>" width='100' alt="<?= $siteOptions->logo->description ?>"> <?php endif ?> Or add new “Unique” status for pages https://processwire.com/blog/posts/pw-3.0.127/ Add this status to the Options page and in the _init.php file get this way: $siteOptions = pages()->get('options'); // or $siteOptions = pages('options');
  8. Hi ... Jonathan Lahijani has a great tutorial on youtube that can help you Simply put, you need to create an option template, then add 2 pages, one in the page tree named options, to which you choose the option template, and under the admin add another page and change the name, for example (admin_options), so that the names are not identical. Choose a process named ProcessPageEdit and save the page ... in admin.php paste the code // Custom Options Page if( page()->name == 'admin_options' ) input()->get->id = pages()->get('options')->id; Finally, you can add some css to hide the options page in the page tree. /** Hook Admin Custom CSS */ $wire->addHookAfter('Page::render', function($event) { if(page()->template != 'admin') return; // Check if is Admin Panel $value = $event->return; // Return Content $templates = urls()->templates; // Get Template folder URL $style = "<link rel='stylesheet' href='{$templates}assets/css/admin.css'>"; // Add Style inside bottom head $event->return = str_replace("</head>", "\n\t$style</head>", $value); // Return All Changes }); You can also download the profile that has the option page created and see how you can create your own options page https://github.com/rafaoski/site-minimal
  9. 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 ?
  10. 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-minimal Live 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_name pages->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:
  11. Thanks ... I am also of the opinion that it is great to have a good basis for further development of the profile that contains the latest additions API ... I think that this profile should be quite simple for users, given that all the latest features are described on the blog ... Anyway, it's nice that it comes in handy ...
  12. This profile can be used as a simple business card or it can be used as a starting profile. Live Example Can download from this link: https://github.com/rafaoski/site-minimal Basic Info Most of the profile settings and translates are in the _init.php file. Functions can be found in the _func.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_name pages->get('options')->site_name Screenshots:
  13. Thanks for the answer ... It seems that the LastPass plugin generate error ... After turning off the add-on LastPass everything has returned to normal ...
  14. Hi, @tpr and thanks you for adding this useful module. After switching on AdminOnSteroids I noticed a small problem appearing when opening and closing the repeater, but only in Mozilla Firefox and Admi Theme Uikit. After opening the single repeater, it remains in the open position. I'm not fluent in JS and I do not know where the error is, but the console shows me information as below. Error: Permission denied to access property "apply" SERVER DETAILS ProcessWire: 3.0.126 PHP: 7.3.1 Webserver: Apache/2.4.35 (Win64) OpenSSL/1.1.1a MySQL: 5.7.24 MODULE DETAILS AdminOnSteroids: 2.0.13 ProcessTracyAdminer: 1.0.6 TracyDebugger: 4.17.22
×
×
  • Create New...