Jump to content

rafaoski

Members
  • Posts

    81
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by rafaoski

  1. 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');

     

    • Like 2
  2. 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?

    • Like 1
  3. 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.
     

    • Like 3
  4. 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

    nested-comments-compressor.thumb.png.c58222da3d24b3be6e4c019c96cb187f.png

    If you want more or less nesting, you must set "Reply depth" in the setting comments field ( this will add a reply button )

    reply-d-compressor.png.4b3e297b41c5be079ef20cf88d7be6ba.png

    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:

    reply-d-compressor.png.4b3e297b41c5be079ef20cf88d7be6ba.png

    And adding options for page nubmers in the setting blog-post template:

    page-numbers-compressor.thumb.png.fcb6058f88f1f7e0058d20771d84b688.png

     

  5. 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

     

  6. 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');

     

     

    • Like 1
  7. 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

     

    • Like 3
  8. 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:

    1. Most of the profile settings and translates are in the _init.php file.
    2. Functions can be found in the _func.php, _uikit.php file.
    3. The entire view is rendered in the _main.php file that uses markup regions.
    4. You can easily add hooks using the ready.php file.
    5. 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
    6. The Author's website's blog entries use URL segments (/ authors / {author-name} /), see views/blog/blog.php for more info.
    7. 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:

    home.thumb.png.f5996ecfcc5fc37d15dd1ebc186dbf60.png

     

    about.thumb.png.4fd3795ec34a8d9407c1b27ea24131e7.png

     

    contact.thumb.png.f0f869498c9e810ca91c3024cf8a3140.pngcontact.thumb.png.f0f869498c9e810ca91c3024cf8a3140.png

     

    blog.thumb.png.973069a68c6f2a62b0d1e82c5c4b4695.png

     

    blog-post.thumb.png.72b68fcc489eaa24b620d86a8b0674e6.png

     

    pages.thumb.png.0a25e27b2dafdac057aafae7123ae429.png

    options.thumb.png.dd94c05c708ebb47a3b1fc8b9d9c2a72.png

     

     

     

     

     

    • Like 7
  9. This profile can be used as a simple business card or it can be used as a starting profile.

    minimal.thumb.png.ec894f98439ca3974bdfe1ca9210491a.png

    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:

    Firefox_Screenshot_2019-07-26T14-19-47.204Z-compressor.thumb.png.b2c646d5d3e422857a6ac565dbf5c402.png

     

    Firefox_Screenshot_2019-07-26T14-20-12.996Z-compressor.thumb.png.2dd8142523150b0e5c5ff6951764e943.png

    Firefox_Screenshot_2019-07-26T14-20-32.552Z-compressor.thumb.png.2337486fbcf58557b8f203b96f336b51.png

    Firefox_Screenshot_2019-07-26T14-21-40.446Z-compressor.thumb.png.160187b932615fd4930d0314d32fb341.png

    Firefox_Screenshot_2019-07-26T14-21-53.519Z-compressor.thumb.png.1e1d0d5cdeffdaf280031b65c8eb9c0e.png

    • Like 5
  10. 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"

    Admin-on-steroids.thumb.gif.043b81476e905d2468529feb4f4967ba.gif

    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

  11. I think it is best to add a photo to the head element as below:

    ( I've added a simple if statement that will check in which template to display the pictures )

    <!DOCTYPE html>
    <html lang="en">
    <head>
    	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
    	<meta name="viewport" content="width=device-width, initial-scale=1" />
    	<title><?php echo $page->title; ?></title>
    	<meta name="description" content="<?php echo $page->summary; ?>" />
    	<link href='//fonts.googleapis.com/css?family=Lusitana:400,700|Quattrocento:400,700' rel='stylesheet' type='text/css' />
    	<link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>styles/main.css" />
    <?php
    // Get Images ( https://processwire.com/docs/fields/images/ )
    $image = $page->images;
    
    // Show only in these templates
    $check_templates = ['home', 'basic-page'];
    if ( in_array($page->template->name, $check_templates) ):
    ?>
    	<style>
    		/* https://css-tricks.com/perfect-full-page-background-image/ */
    		body {
    		  /* background: url(<?php // if($image) echo $image->first()->url;?>) no-repeat center center fixed; */
    			background: linear-gradient( rgba(0, 0, 0, 0.91), rgba(2, 35, 50, 0.82) ),
    									url("<?php if($image) echo $image->first()->url;?>") no-repeat center center fixed;
    		  background-size: cover;
    		  height: 100%;
    		}
    		p, h1, h2, h3 {
    			color: aliceblue;
    		}
    		a {
    			color: tomato;
    		}
    		.summary {
    			color: aliceblue;
    		}
    	</style>
    <?php endif; ?>
    </head>
    <body>
    
    <main id='main'>

    Remember to download images correctly if you use the images field, for example:

    https://processwire.com/docs/fields/images/

    <?php
    $image = $page->images;
    if($image) echo $image->first()->url;
    ?>

    You can also check the selected page where you want to display the picture:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
    	<meta name="viewport" content="width=device-width, initial-scale=1" />
    	<title><?php echo $page->title; ?></title>
    	<meta name="description" content="<?php echo $page->summary; ?>" />
    	<link href='//fonts.googleapis.com/css?family=Lusitana:400,700|Quattrocento:400,700' rel='stylesheet' type='text/css' />
    	<link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>styles/main.css" />
    <?php
    // Get Images ( https://processwire.com/docs/fields/images/ )
    $image = $page->images;
    
    // Show only in these pages
    $check_page_name = ['home', 'about'];
    if ( in_array($page->name, $check_page_name) ):
    ?>
    	<style>
    		/* https://css-tricks.com/perfect-full-page-background-image/ */
    		body {
    		  /* background: url(<?php // if($image) echo $image->first()->url;?>) no-repeat center center fixed; */
    			background: linear-gradient( rgba(0, 0, 0, 0.91), rgba(2, 35, 50, 0.82) ),
    									url("<?php if($image) echo $image->first()->url;?>") no-repeat center center fixed;
    		  background-size: cover;
    		  height: 100%;
    		}
    		p, h1, h2, h3 {
    			color: aliceblue;
    		}
    		a {
    			color: tomato;
    		}
    		.summary {
    			color: aliceblue;
    		}
    	</style>
    <?php endif; ?>
    </head>
    <body>
    
    <main id='main'>

     

    If you use a REGULAR profile wchich using new template file strategy, it's very simple to add styles in the selected template like home

     

    <?php namespace ProcessWire;
    
    /* home.php */
    
    // get most recent blog post
    $blog = pages()->get('/blog/');
    $blogPost = $blog->child();
    
    // Get Images ( https://processwire.com/docs/fields/images/ )
    $image = $page->images;
    ?>
    
    <head id='html-head' pw-append>
    <style>
    	/* https://css-tricks.com/perfect-full-page-background-image/ */
    	body {
    		/* background: url(<?php // if($image) echo $image->first()->url;?>) no-repeat center center fixed; */
    		background: linear-gradient( rgba(0, 0, 0, 0.91), rgba(2, 35, 50, 0.82) ),
    								url("<?php if($image) echo $image->first()->url;?>") no-repeat center center fixed;
    		background-size: cover;
    		height: 100%;
    	}
    	p, h1, h2, h3 {
    		color: aliceblue;
    	}
    	a {
    		color: tomato;
    	}
    	.summary {
    		color: aliceblue;
    	}
    	.uk-card h3 {
    		color: black;
    	}
    	.uk-card p {
    		color: black;
    	}
    </style>
    </head>
    
    <h1 id='content-head'>
    	<?=page()->headline?>
    </h1>
    
    <div class='uk-margin-top' id='content-body'>
    	<?=page()->body?>
    	<hr>
    	<p class='uk-margin-small'>
    		<a class='uk-button uk-button-link uk-link-muted' href='<?=$blog->url?>'>
    			In the blog
    		</a>
    	</p>
    	<?=ukBlogPost($blogPost)?>
    	<p class='uk-margin-small'>
    		<a href='<?=$blog->url?>'>More blog posts <?=ukIcon('arrow-right')?></a>
    	</p>
    </div>
    
    <aside id='sidebar'>
    	<?=ukNav(pages()->get('/categories/')->children)?>
    	<div class='uk-card uk-card-default uk-card-hover uk-card-body uk-margin-medium-top'>
    		<?=page()->sidebar?>
    	</div>
    </aside>

     

    • Like 5
  12. Maybe try using two foreach loops:

    <?php
    foreach ($pages->get('/portal/movies/')->children as $movieCategory) {
    
    echo "<h3><a href='$movieCategory->url'>$movieCategory->title</a></h3>";
    
    echo '<ul>';
    // Get movie Children
    foreach ($movieCategory->children as $movie ) {
    echo "<li><a href='$movie->url'> $movie->title </a></li>";
    }
    echo '<ul>';
    
    }
    ?>

     

    Or using $pages->find() ... Show children from the template, which is assigned to a single movie:

    <ul><?php // https://processwire.com/api/ref/pages/find/
      $items = $pages->find("template=single-movie, limit=12");
      // Loop
      foreach ($items as $item) {
        echo "<li><a href='$item->url'>$item->title</a></li>";
      }
    ?></ul>
    <?php // Pagination https://processwire.com/api/modules/markup-pager-nav/
      $pagination = $items->renderPager();
      echo $pagination;?>

     

    • Like 1
  13. If you want the customer to easily update the fields you can create a translate and translate_string templates.

    You will be able to easily create translations using pages ...

    Next, create function inside the _translate file to show translateable field title as in the movie, for example:

    <?php namespace ProcessWire;
    
    function trStr($page, $str) {
    
    $tr_page = pages()->get("/translate/$page/")->title;
    
    if($tr_page) {
    
        return $tr_page;
    
    } else {
    
        return $str;
    
    }
    
    }
    
    // Translate Strings
    page()->ts = [
    
    'your_awesome_string' => trStr('your-awesome-string', __('Your Awesome Strings')),
    
    ];

    And display on the site:

    <h1><?=page()->ts['your_awesome_string']?></h1>

     

    You can download this profile from here: 

     

    • Like 2
  14. Hi ... Here you should find a lot about the translations

    https://processwire.com/api/multi-language-support/code-i18n/

    I do not know if this is the best solution, but it works for me ...

    Thanks to this, I do not have to search for translations in all of the template's peaks ...

    So I create a simple file responsible for all translations

    _translate.php

    Include this file inside _init.php

    include_once('./_func.php');

    include_once('./_translate.php');

    And define in the table as below
     

    <?php namespace ProcessWire;
    // Translate Strings
    page()->ts = [
    
    // Language => locale / code prefx
    'locale' => _x('en_US', 'HTML locale code'),
    'lang_code' => _x('en', 'HTML language code'),
    
    // Main Page ( main.php )
    'site_name' => __('Your Site Name'),
    'logo_alt' => __('Show My Awesome Logo'),
    
    // Archives Page
    's_archives' => __('Select The Archives'),
    'date' => __('Date'),
    ];

    Then you can call globally using page()

    <h1><?=page()->ts['site_name'];?></h1>

    And there is a pro option Functional Fields:

    https://processwire.com/blog/posts/functional-fields/

    But I can not say too much about it because I have not tested it but it looks interesting 🙂

    • Like 1
    • Thanks 1
  15. Hi and welcome ... You can add your own field in a very simple way ...

    See also here https://processwire.com/api/variables/page/

    You have to go to the template that the page uses and add a few lines of php code as below ...

    <?php echo page()->custom_field?>
    <?php echo $page->custom_field?>
    <?php echo page('custom_field')?>

    See this short video in which I used the regular UIKIT 3 profile which is in the Processwire DEV version

    You can display this field in the _main.php file in the same way, or if for example, you create an option page, you can use this way in which the field will be visible on all pages  https://processwire.com/api/variables/pages/ ...

    		<h1>Home Page Field ( / ) <?= pages('/')->custom_field ?></h1>
    		<h1>Home Page Field ( / ) <?= pages()->get('/')->custom_field ?></h1>
    
    		<h1>About Page Field ( /about/ ) <?= pages('/about/')->headline ?></h1>
    		<h1>About Page Field ( /about/ ) <?= pages()->get('/about/')->headline ?></h1>

    This old tutorial is also good to starting learn Processwire :

    https://processwire.com/docs/tutorials/hello-worlds/

    • Like 2
  16. Hi everyone ...

    Generally, this is about the new mailHTML() function that does not work correctly on processwire 3.0.110

    https://github.com/processwire/processwire/blob/dev/wire/core/WireMailTools.php#L291
    https://processwire.com/api/ref/mail/mail-h-t-m-l/

    I do not know if I'm making a mistake trying to send an e-mail or if it's a bug in the core
    This is my code:

    <?php
    // $m = $mail->new(); // option A
    // $m = new WireMail(); // option B
       $m = wireMail(); // option C
       $m->mailHTML('alex@gmail.com', 'Hello', '<html><body><h1>Message Body</h1></body></html>');
       $m->send();
    ?>

    wire-mail.thumb.png.64ed184899598883d662c7e5b08f0249.png


    Details from Tracy Debugger

    SERVER DETAILS
    ProcessWire: 3.0.110
    PHP: 7.2.8
    Webserver: Apache/2.4.34 (Unix)
    MySQL: 10.1.34-MariaDB

    SERVER SETTINGS
    allow_url_fopen: 1
    max_execution_time: 120 (changeable)
    max_input_nesting_level: 64
    max_input_time: 60
    max_input_vars: 1000
    memory_limit: 256M
    post_max_size: 8M
    upload_max_filesize: 20M
    xdebug:
    xdebug.max_nesting_level:
    mod_rewrite: 1
    mod_security: *confirmed off
    GD: 2.2.5
    GIF: 1
    JPG: 1
    PNG: 1
    EXIF Support:
    FreeType: 1
    Imagick Extension:


    MODULE DETAILS
    TracyDebugger: 4.11.13

×
×
  • Create New...