Jump to content

Learn & Launch project


MilenKo
 Share

Recommended Posts

14 minutes ago, MilenKo said:

Any ideas how to better organize the structure if you think my approach is not needed/the best following the logic?

Maybe I do not get what you are aiming to do, but it is possible to get pages by defining more than one template in your selector, so you do not have to put your pages under the same parent, just to get them with $page->children:

eg.: $pages->find("template=article|news|faq");

You might also want to check out @LostKobrakai's Paginator module to list and paginate pages from different templates easily.

  • Like 1
Link to comment
Share on other sites

Hello Szabesz. It is interesting to know that PW can handle multiple selectors and it would definitely come in use when I get to that point.

I want to explain my idea and the needs as I feel as it is not clear. It might become easier to understand my goal by looking at the screenshot I took from the HTML view of the theme (image attached). The need is to have a parent page for some HowTo division by topic and then show a few (in the specific case 3 child pages). On top of that, it is needed to show how many child pages does the parent contain and when clicking to View all, to show only the howto's from that specific parent.

In this particular case, I thought to have a structure like this:

|=HowTos (parent of all HowTo pages but a child of the Home)

|== Account settings (child of Howtos and parent of all Account settings howto pages)

|=== Howto1 (howtos itself)

|=== Howto2

!== API Questions (child of Howtos and parent of all API Questions howtos)

|=== Howto1

|=== Howto2

|== Customization (child of Howtos and parent of all Customization howtos)

|=== Howto1

|=== Howto2

|== Mobile apps (child of Howtos and parent of all Mobile apps howtos)

|=== Howto1

|=== Howto2

 

So far I think the best approach would be to follow that structure and then list all the child of Howtos and underneath to show N-pages of the howtos. Having done the things this way, in case of a need to add another child of Howtos and parent of another topic, it would be listed automatically under the already existing in the frontend and of course the N-pages it contains underneath.

I hope I did explained it better now as I understand it is hard to explain sometimes what is in the head.

Btw, thanks for the shared ideas and the module of @LostKobrakai. So far I am trying to learn how to work with the standard API tools of PW and not extend the functionality with additional modules. I have nothing against the use of modules and am grateful to those who spend their time in creating and sharing them.

NowKnow-howto-categories.png

Link to comment
Share on other sites

Ok. I gave a second thought last night and decided that the howto's would be added only to the Articles, so there will be no need to touch the news and FAQ. Initially I thought to use the FAQ for a quick/small howto's however it seems better to add a few descriptions how to add the articles etc. rather than use it as a knowledge sharing. So the structure would change:

|= Home

|== FAQ

|== News

|== Articles

|=== Account settings

|=== API Questions

|=== Customizations

|=== Mobile Apps

I think that this approach would cause less confusion and would allow to pull up all children of Articles and show N-pages of each on the main. Following the structure above, all that is needed to be done is to have add Account Settings, API Questions, Customizations and Mobile Apps as children of Articles and start adding the howto pages.

Let's see how it goes applying the changes. The challenge would be to pull the list of all the children and the N-latest/random pages of it. I am not sure yet do we need to split the News the same way but for the moment I am going to concentrate on the Articles as this is what is the most needed functionality for our team.

 

Link to comment
Share on other sites

On 1/5/2017 at 6:10 AM, MilenKo said:

Btw, thanks for the shared ideas and the module of @LostKobrakai. So far I am trying to learn how to work with the standard API tools of PW and not extend the functionality with additional modules. I have nothing against the use of modules and am grateful to those who spend their time in creating and sharing them.

Hi, This is quite understandable (I'm often in this very same boat too), but if you take a look at the code, you can see that it is basically a simple helper so that you do not have to reinvent the wheel over an over again.

BTW, I did not have the time to read through your posts, but looking at the screenshot I remember seeing it in the past, I mean using this interface for some time and what I recall is that I hated it, because I could not find my way around the articles easily, it felt like a big mess of hyperlinked docs, and it was hard to recognize which article I have already read. (What sort of system/implementation it was I do not know). Maybe I was just to dumb to get the logic behind it, I do not know, but I'm glad I do not have to see it again.

  • Like 1
Link to comment
Share on other sites

@szabesz you made my day ;). To be honest, I do not think you were dumb not to see it properly organized. It is just to have the proper tools, some willing to achieve the task and for sure some support from friends and other devs that can have the proper approach. I think it would work the way I see it, but thinking and having it done are two different things. I will definitely see the paginator as I am not sure the search results would be paginated (haven't tested them yet as I did not have added 10-20 pages matching the same search term etc.) But this is on the way :)

So far I will start adding some topics and see how to point them out on the main page. Who knows, maybe the approach would be useful for the others one day that are struggling to get the things done and need a similar structure. If it was done on Wordpress, it would be done in PW and would be way more elegant as a code as well as a logic :)

  • Like 1
Link to comment
Share on other sites

I started thinking this morning... If I want to apply the delayed output to a theme, what would be the best approach to such a complex theme containing tons of blocks etc. on the main page. Should I decide which part of the page would be the main "body" output and the rest to be included or added, so that any other page applies the same content and be able to push $body/$content at the same spot or what is the best approach for that. If I am not wrong, the init.php (file loaded before) and main.php (the file loaded after) are applied to all pages in the profile but not exclude the home page. I checked the skyscrapers theme however the main page does not contain that many features on the main so I am still struggling to figure out what is the best approach in a more complex website.

For sure I can do a standard page template but am trying to learn the best practices and start applying those rather than just do what you can. Even if it takes more time to process and figure out all the bits and pieces, I am willing to invest my personal time into something so elegant leading to a better and more productive result :)

Link to comment
Share on other sites

Getting back to NowKnow, I moved on to add a few child pages of Articles (Software, Hardware, Network, Cisco). I decided that pointing to that child should list all the child pages topic related to the parent, so would point the parent to have the same template as the articles itself (articles). However, I am struggling to do that as in the drop down list I only have the articles-inner which would list the article itself (title, image, body text etc.) Am I missing something here or there is another way to assign the Articles template to its "groupped child" (Software, Hardware etc.)
My goal is that if somebody browse an url: http://FQDN/articles/software - that would show all the software howto child pages having the same listing template as Articles. Having clicked further on the title, would link to the child page content and being styled by the articles-inner template.

Any suggestions or ideas how to achieve that? I did not test to create the a page under Home and then move it to articles to see if its template would change, however I am not sure this is the best way to achieve it?

Link to comment
Share on other sites

I tried to add a page assigning the article template to it and then move it, however, PW is not allowing that to be done and shows the error attached. Now I am in doubt how could this be achieved as obviously, my logic is against PW logic or rules. All I am looking at is to have sort of a "Category" with a "Child category" in it to be listed with the same template as the Category one. For sure I am able to create Software, News, Hardware and Cisco as parents and start adding the child pages to them, however they would not be listed as children of Articles. One way to approach this would be to use selectors as suggested earlier, however any new HowTo category would cause a code edit instead of listing the new page automatically. Now I plan to add only 4 but what if there are 100?

Link to comment
Share on other sites

5 hours ago, MilenKo said:

so I am still struggling to figure out what is the best approach in a more complex website.

Hi, This is my preferred way of organizing things:

So I prefer using wireRenderFile() in the first place. Also, the pattern used: https://github.com/NinjasCL/wire-render-pattern is a good example of separating the "controller functions/template files" from the "template views".

An important note on using wireRenderFile():

So if you start using it, you might want to pass $page along instead of managing lots of individual variables like it is implemented in the above mentioned Ghost Blog Clone.

  • Like 1
Link to comment
Share on other sites

@szabesz Thanks very much for the info. My guess is that I am more like a guy that looks at examples and finds the interesting approaches, so the ghost clone seems like another perfect example to dig in and squeeze some knowledge from the more skilled and advanced coders.

  • Like 1
Link to comment
Share on other sites

7 hours ago, MilenKo said:

If I want to apply the delayed output to a theme, what would be the best approach to such a complex theme containing tons of blocks etc. on the main page.

There's no absolutely right or wrong way - if you asked 10 people you'd probably get 10 different answers. It comes down to what you find most comfortable to read, write and maintain. Personally I like a single auto-appended main.php containing the HTML head, body and any "framework" markup that will appear on all pages. For blocks of content I use variables defined in an auto-prepended init.php and overwritten in template files where needed. I like to use output buffering when populating my "block" variables:

<?php ob_start(); // $side_col ?>
<div class="side-col">
    <p>Something else here.</p>
    <?php // some PHP here ?>
</div>
<?php $side_col = ob_get_clean(); ?>

 

7 hours ago, MilenKo said:

If I am not wrong, the init.php (file loaded before) and main.php (the file loaded after) are applied to all pages in the profile but not exclude the home page.

Generally my approach would be to use main.php for all templates including the home template - anything unique to the home template would be inside the main "block" variables. But here's another way:

I have a $use_main variable defined as true in init.php, and at the top of main.php I have

if(!$use_main) return;

So if I don't want the contents of main.php appended I can set $use_main to false in a template and then use alternative markup. You could do this in your home template.

 

5 hours ago, MilenKo said:

I decided that pointing to that child should list all the child pages topic related to the parent, so would point the parent to have the same template as the articles itself (articles).

I think in this case I would create a different template for this ("article_categories"), but it would "extend" the parent articles category so I'm only changing the parts that need to be different. I do this by including the template to be extended at the start of the template file.

// template extends...
include './articles.php';

Then in article_categories I overwrite the variables I want to change from what is defined in the articles template.

Alternatively you could use a single template for both articles and article_categories and use some logic inside it to change the output.

if($page->parent->name === 'articles') {
    // then this is one of the article category pages
}

 

5 hours ago, MilenKo said:

I tried to add a page assigning the article template to it and then move it, however, PW is not allowing that to be done and shows the error attached.

This is probably the result of template "Family" settings.

2017-01-09_151833.png

  • Like 3
Link to comment
Share on other sites

Robin S, I am EXTREMELY thankful to you as it was really the family setting that I missed out somehow. I was able to apply the Articles template to Software "category" being a child theme and assign to it a few child howtos. For sure I will have to deal with an error as the theme was not intended for this approach and I got this:

Notice: Undefined variable: result in C:\OpenServer\domains\nowknow.pw\site\assets\cache\FileCompiler\site\templates\articles.php on line 55

Fatal error: Call to a member function renderPager() on a non-object in C:\OpenServer\domains\nowknow.pw\site\assets\cache\FileCompiler\site\templates\articles.php on line 55

where the Articles template code around line 55 contains the pagination code:

<footer class="archive-footer text-center">
	<?php echo $result->renderPager(array(	
		"nextItemLabel" => __("»"),
		"previousItemLabel" => __("«"),				
		//"firstNumberItemClass" => "pagination__item--first-num",
		//"lastNumberItemClass" => "pagination__item--last-num",
		//"previousItemClass" => "pagination__item--prev",
		//"nextItemClass" => "pagination__item--next",
		//"firstItemClass" => "pagination__item--first",
		//"lastItemClass" => "pagination__item--last",
		"currentItemClass" => "active",
		//"itemMarkup" => "<li class='pagination__item {class}'>{out}</li>",
		//"linkMarkup" => "<a class='pagination__item-link' href='{url}'><span>{out}</span></a>"
		"listMarkup" => "<ul class='pagination pagination-custom'>{out}</ul>",										
		));
	?>	
</footer><!-- .archive-footer -->

 

Link to comment
Share on other sites

13 hours ago, MilenKo said:

If I am not wrong, the init.php (file loaded before) and main.php (the file loaded after) are applied to all pages in the profile but not exclude the home page.

Just wanted to add that you can override an automatically prepended/appended file for a template on the Files tab of Edit Template.

2017-01-09_193403.png

If you know you never want those automatically prepended/appended files for the template then this is the way to go. The $use_main approach is more suitable when some of the time you want the appended file and some of the time you don't (for an AJAX-loaded page, for instance).

  • Like 1
Link to comment
Share on other sites

I had a few minutes for a quick look and searched the forum about showing the child of a child. Found some very resourceful info and decided to organize the things elegantly. To do this, I created a new template calling it articles-categories and assigned to it the articles fields.

After playing with $render I was able to pull up the list of articles including the children (software etc.) Then it was just a matter of moving the child pages to software and allowing the articles template for the new child to be articles-categories. Then I came up with the idea to list only the child-cattegories in articles so that a visitor can choose what he is looking for and click on the proper howto group.

Once I get back home I will share the code I used as I still need to work on it a bit in order to make it fully working. Having this approach eliminates the page duplication as if you browse the /articles/ you will only see the child but not their children. For sure, if you click on the children in Articles, then you will see all the parent-name related articles. Let's see how that goes and hopefully there will be no more surprises on this.

To make the theme looking better I will remove the date and time of adding from the articles template as it would only lost the groups and it is not needed  to show such info ;)

  • Like 1
Link to comment
Share on other sites

Phew... after messing up the things quite a few times and getting confused about showing the child of a child of a child, I decided to step off for some time and then come back with some fresh ideas.

The first few minutes were crucial as everything started working as it should with minimal changes to the original Articles template.

Here is the articles.php

Spoiler

<?php include ('./includes/header.php');?>
		
<?php include ('./includes/breadcrumbs.php');?>
		
		<div id="main" class="site-main clearfix">
			<div class="container">
	
				<div class="content-area">
					<div class="row">

						<div id="content" class="site-content col-md-9">
						
							<header class="archive-header">
								<h1 class="archive-title"><?php echo $title;?></h1>
							</header><!-- .archive-header -->
							
							<blockquote class="archive-description">
								<p><?php echo $headline;?></p>
							</blockquote><!-- .archive-description -->
							
							<div class="archive-list archive-article">

								<?php if($page->numChildren) {
									
									//	$result = $page->children("limit=10"); $result has a limit here if needed
										$result = $page->children;
										
										// render the children 
										echo "<article class='hentry'>";
										
											foreach($result as $child) { ?>
												<header class="entry-header">
													<i class="fa fa-list-alt fa-2x fa-fw pull-left text-muted"></i>
													<h2 class="entry-title h4"><a href="<?php echo $child->url;?>" rel="bookmark"><?php echo $child->title;?></a></h2>
												</header><!-- .entry-header -->
													
												<footer class="entry-footer">
													<div class="entry-meta text-muted">
														<span class="date">
															<i class="fa fa-clock-o fa-fw"></i>
															<time datetime="<?php echo date('Y-j-d, G:i', $child->created); ?>"><?php echo wireRelativeTimeStr($child->created);?></time>
														</span>
														<span class="category"><i class="fa fa-folder-open-o fa-fw"></i> Contains: <a href="<?php echo $page->rootParent->url?>"><?php echo $page->rootParent->title;?></a></span>
													</div><!-- .entry-meta -->
												</footer><!-- .entry-footer -->
											<?php }
										
										echo "</article><!-- .hentry -->";

										// render pager again? ok
										
									};?>
							
							</div><!-- .archive-list -->
					
							<footer class="archive-footer text-center">
								<?php echo $result->renderPager(array(	
									"nextItemLabel" => __("»"),
									"previousItemLabel" => __("«"),				
									//"firstNumberItemClass" => "pagination__item--first-num",
									//"lastNumberItemClass" => "pagination__item--last-num",
									//"previousItemClass" => "pagination__item--prev",
									//"nextItemClass" => "pagination__item--next",
									//"firstItemClass" => "pagination__item--first",
									//"lastItemClass" => "pagination__item--last",
									"currentItemClass" => "active",
									//"itemMarkup" => "<li class='pagination__item {class}'>{out}</li>",
									//"linkMarkup" => "<a class='pagination__item-link' href='{url}'><span>{out}</span></a>"
									"listMarkup" => "<ul class='pagination pagination-custom'>{out}</ul>",										
									));
								?>	
							</footer><!-- .archive-footer -->

						</div><!-- #content -->

<?php include ('./includes/sidebar.php');?>

					</div>
				</div><!-- .content-area -->
	
			</div>
		</div><!-- #main -->
		
<?php include ('./includes/footer.php');?>

 

 

And here is the articles-category.php:

Spoiler
Quote

<?php include ('./includes/header.php');?>
        
<?php include ('./includes/breadcrumbs.php');?>
        
        <div id="main" class="site-main clearfix">
            <div class="container">
    
                <div class="content-area">
                    <div class="row">

                        <div id="content" class="site-content col-md-9">
                        
                            <header class="archive-header">
                                <h1 class="archive-title"><?php echo $title;?></h1>
                            </header><!-- .archive-header -->
                            
                            <blockquote class="archive-description">
                                <p><?php echo $headline;?></p>
                            </blockquote><!-- .archive-description -->
                            
                            <div class="archive-list archive-article">
                            
                            

                                <?php if($pages->get('/articles/')->numChildren) {
                                    
                                        $result = $pages->get('/articles/')->children("limit=10");
                                        
                                        // render the children 
                                        echo "<article class='hentry'>";
                                        
                                            foreach($result as $child) { ?>
                                                <header class="entry-header">
                                                    <i class="fa fa-list-alt fa-2x fa-fw pull-left text-muted"></i>
                                                    <h2 class="entry-title h4"><a href="<?php echo $child->url;?>" rel="bookmark"><?php echo $child->title;?></a></h2>
                                                </header><!-- .entry-header -->
                                                    
                                                <footer class="entry-footer">
                                                    <div class="entry-meta text-muted">
                                                        <span class="date">
                                                            <i class="fa fa-clock-o fa-fw"></i>
                                                            <time datetime="<?php echo date('Y-j-d, G:i', $child->created); ?>"><?php echo wireRelativeTimeStr($child->created);?></time>
                                                        </span>
                                                        <span class="category"><i class="fa fa-folder-open-o fa-fw"></i> <a href="<?php echo $page->rootParent->url?>"><?php echo $page->rootParent->title;?></a></span>
                                                    </div><!-- .entry-meta -->
                                                </footer><!-- .entry-footer -->
                                            <?php }
                                        
                                        echo "</article><!-- .hentry -->";

                                        // render pager again? ok
                                        
                                    };?>
                            
                            </div><!-- .archive-list -->
                    
                            <footer class="archive-footer text-center">
                                <?php echo $result->renderPager(array(    
                                    "nextItemLabel" => __("»"),
                                    "previousItemLabel" => __("«"),                
                                    //"firstNumberItemClass" => "pagination__item--first-num",
                                    //"lastNumberItemClass" => "pagination__item--last-num",
                                    //"previousItemClass" => "pagination__item--prev",
                                    //"nextItemClass" => "pagination__item--next",
                                    //"firstItemClass" => "pagination__item--first",
                                    //"lastItemClass" => "pagination__item--last",
                                    "currentItemClass" => "active",
                                    //"itemMarkup" => "<li class='pagination__item {class}'>{out}</li>",
                                    //"linkMarkup" => "<a class='pagination__item-link' href='{url}'><span>{out}</span></a>"
                                    "listMarkup" => "<ul class='pagination pagination-custom'>{out}</ul>",                                        
                                    ));
                                ?>    
                            </footer><!-- .archive-footer -->

                        </div><!-- #content -->

<?php include ('./includes/sidebar.php');?>

                    </div>
                </div><!-- .content-area -->
    
            </div>
        </div><!-- #main -->
        
<?php include ('./includes/footer.php');?>

 

 

 

Link to comment
Share on other sites

Please note that I did not look at the opening and ending PHP for the moment so I am leaving the cleanup and code elegance for the end when I will move to testing and optimization. I decided to do it that way hoping that with the time I will gain a bit more coding skills and that would allow me to rethink the approach and have the theme properly optimized.

As of now, here is what was achieved:

== HOME PAGE ==

1. Header logo is uploaded using fields

2. Header Menu is set statically (except Home link pointed to $config->urls->root;) As far as we have only 5 links, I did not bother using API even though it is not hard to do it and the code was posted earlier.

3. The 3 Features blocks under the header were done by a defined field in Homepage using a repeater (every feature contains the fa-icon, title and body text).

4. About US block in the footer is defined by About Us field in the Homepage. The plan is at the end to move all the settings to a Settings page and does the proper calls from there, however, let's not complicate the things more for the moment.

5. Last but not the least for the HomePage - the search form is working fine even though I am planning to mess up with the Ajax search later to make it, even more, friendlier and interactive.

== Articles ==

1. Articles page shows up a title and some nice headline text (as per the theme styling) - all pulled out by the template fields.

2. Articles page lists now all the child pages that are used like containers/categories to hold the thematically sorted child pages. As far as I changed the idea today, I will have to look and replace the date of publishing and parent category with the number of howtos in each child under Articles.

3. About US in the footer did not show, so I had to change the code from $page->about  to  $pages->get('/')->about

== NEWS == 

1. Same things have been applied as per Articles.

2. Styling has been changed to add an image for every news. I still need to add a check if an image exists in the post and if not, assign a default one.

Outside the pages, every inner page has the breadcrumbs automatically pulled up and does not need any fine tuning.

The next step would be to tie up the Software, Hardware, Network on the main page and sho N-number of pages there too with some sorting applied.

Now after playing with the child of a child I hope that it won't be that difficult to achieve it.

Link to comment
Share on other sites

Hello again. I decided that it was too easy to achieve the list of the children of a child, so to have some extra fun and make it look better, I decided that it is time to mess up with the counters and show in the Articles template the number of howto pages in every child-category. I am playing now with that and once I have some progress, will share it up (or ask for help ;) )

This counter would not be just a cosmetic but is a needed feature for the home page where I will have to manage to list the parent-categories with N-howto child pages and a counter of the child in it. So let's have fun.

Link to comment
Share on other sites

OK. I had some progress but still it is no go yet.

By using the following I was able to show the ID of the child pages: <?php echo "Contains: " . $child->children; ?>

I thought that I can just count the $child->children but instead of getting the right number as it is showing the proper value of ID's it just shows the number of the parent (1).

So $child->children in my case shows the 5 howto pages ID's but count('$child->children') returns the number of the children of Articles which in my case is one.

Any suggestions or corrections as I feel it is something silly (again) I am missing here :)

NowKnow-Child-Count.jpg

Link to comment
Share on other sites

@fbg13 Hahaha, I knew I am close and it was just to discover the count but sometimes the lack of PHP knowledge is causing some funny situations. Thank you fbg13, one less task to deal with.

Do you think it is a good idea to have my approach to counting the child pages? As I am using:

<?php echo "Contains: " . count($child->children); ?> and it works fine, but might not be that elegant ;)

Anyway, I am attaching the latest changes, as I had to clear out the parent category from articles.php and the articles-category.php. It would not make sense to have the title above the listings in H1 saying Network and under every howto page to have either the parent (Articles) or the parent-category (Network, Software etc.) Instead, I just kept the date of adding for articles-category.php 

articles.php:

Spoiler

<?php include ('./includes/header.php');?>
		
<?php include ('./includes/breadcrumbs.php');?>
		
		<div id="main" class="site-main clearfix">
			<div class="container">
	
				<div class="content-area">
					<div class="row">

						<div id="content" class="site-content col-md-9">
						
							<header class="archive-header">
								<h1 class="archive-title"><?php echo $title;?></h1>
							</header><!-- .archive-header -->
							
							<blockquote class="archive-description">
								<p><?php echo $headline;?></p>
							</blockquote><!-- .archive-description -->
							
							<div class="archive-list archive-article">

								<?php if($page->numChildren) {
									
									//	$result = $page->children("limit=10"); $result has a limit here if needed
										$result = $page->children;
										
										// render the children 
										echo "<article class='hentry'>";
										
											foreach($result as $child) { ?>
												<header class="entry-header">
													<i class="fa fa-list-alt fa-2x fa-fw pull-left text-muted"></i>
													<h2 class="entry-title h4"><a href="<?php echo $child->url;?>" rel="bookmark"><?php echo $child->title;?></a></h2>
												</header><!-- .entry-header -->
													
												<footer class="entry-footer">
													<div class="entry-meta text-muted">
														<span class="category"><i class="fa fa-folder-open-o fa-fw"></i> <?php echo "Contains: " . count($child->children); ?> articles</span>
													</div><!-- .entry-meta -->
												</footer><!-- .entry-footer -->
											<?php }
										
										echo "</article><!-- .hentry -->";

										// render pager again? ok
										
									};?>
							
							</div><!-- .archive-list -->
					
							<footer class="archive-footer text-center">
								<?php echo $result->renderPager(array(	
									"nextItemLabel" => __("»"),
									"previousItemLabel" => __("«"),				
									//"firstNumberItemClass" => "pagination__item--first-num",
									//"lastNumberItemClass" => "pagination__item--last-num",
									//"previousItemClass" => "pagination__item--prev",
									//"nextItemClass" => "pagination__item--next",
									//"firstItemClass" => "pagination__item--first",
									//"lastItemClass" => "pagination__item--last",
									"currentItemClass" => "active",
									//"itemMarkup" => "<li class='pagination__item {class}'>{out}</li>",
									//"linkMarkup" => "<a class='pagination__item-link' href='{url}'><span>{out}</span></a>"
									"listMarkup" => "<ul class='pagination pagination-custom'>{out}</ul>",										
									));
								?>	
							</footer><!-- .archive-footer -->

						</div><!-- #content -->

<?php include ('./includes/sidebar.php');?>

					</div>
				</div><!-- .content-area -->
	
			</div>
		</div><!-- #main -->
		
<?php include ('./includes/footer.php');?>

 

 
 

And here is the articles-category.php:

Spoiler

<?php include ('./includes/header.php');?>
		
<?php include ('./includes/breadcrumbs.php');?>
		
		<div id="main" class="site-main clearfix">
			<div class="container">
	
				<div class="content-area">
					<div class="row">

						<div id="content" class="site-content col-md-9">
						
							<header class="archive-header">
								<h1 class="archive-title"><?php echo $title;?></h1>
							</header><!-- .archive-header -->
							
							<blockquote class="archive-description">
								<p><?php echo $headline;?></p>
							</blockquote><!-- .archive-description -->
							
							<div class="archive-list archive-article">

								<?php if($page->numChildren) {
									
									//	$result = $page->children("limit=10"); $result has a limit here if needed
										$result = $page->children;
										
										// render the children 
										echo "<article class='hentry'>";
										
											foreach($result as $child) { ?>
												<header class="entry-header">
													<i class="fa fa-list-alt fa-2x fa-fw pull-left text-muted"></i>
													<h2 class="entry-title h4"><a href="<?php echo $child->url;?>" rel="bookmark"><?php echo $child->title;?></a></h2>
												</header><!-- .entry-header -->
													
												<footer class="entry-footer">
													<div class="entry-meta text-muted">
														<span class="date">
															<i class="fa fa-clock-o fa-fw"></i>
															<time datetime="<?php echo date('Y-j-d, G:i', $child->created); ?>">Added: <?php echo wireRelativeTimeStr($child->created);?></time>
														</span>
													<!--	<span class="category"><i class="fa fa-folder-open-o fa-fw"></i> Parrent: <a href="<?php echo $page->rootParent->url?>"><?php echo $page->rootParent->child->title;?></a></span> -->
													</div><!-- .entry-meta -->
												</footer><!-- .entry-footer -->
											<?php }
										
										echo "</article><!-- .hentry -->";

										// render pager again? ok
										
									};?>
							
							</div><!-- .archive-list -->
					
							<footer class="archive-footer text-center">
								<?php echo $result->renderPager(array(	
									"nextItemLabel" => __("»"),
									"previousItemLabel" => __("«"),				
									//"firstNumberItemClass" => "pagination__item--first-num",
									//"lastNumberItemClass" => "pagination__item--last-num",
									//"previousItemClass" => "pagination__item--prev",
									//"nextItemClass" => "pagination__item--next",
									//"firstItemClass" => "pagination__item--first",
									//"lastItemClass" => "pagination__item--last",
									"currentItemClass" => "active",
									//"itemMarkup" => "<li class='pagination__item {class}'>{out}</li>",
									//"linkMarkup" => "<a class='pagination__item-link' href='{url}'><span>{out}</span></a>"
									"listMarkup" => "<ul class='pagination pagination-custom'>{out}</ul>",										
									));
								?>	
							</footer><!-- .archive-footer -->

						</div><!-- #content -->

<?php include ('./includes/sidebar.php');?>

					</div>
				</div><!-- .content-area -->
	
			</div>
		</div><!-- #main -->
		
<?php include ('./includes/footer.php');?>

 

 
 

Well, after having that functionality fully achieved, I am starting to think should I move to the comments of the how-tos and news. I checked out Ryan's information about the comments and in theory, it seemed sort of easy to implement. Will start playing with that and see how it goes ;)

Link to comment
Share on other sites

Btw, it worth mentioning that I am thinking to play a bit at the end of the theme development with articles and articles-category as I am sure if I add a few conditions and checks for the page, I can easily combine them and avoid unnecessary file duplication. So far I am trying to achieve the functionality, and then I will start polishing it. 

The funny thing is that the topic has been viewed about 2000 times but a few people share bravely their experience. Even if someone is not a coder, it would worth sharing an idea, better approach, even if it is just a logic. As it says, there is no right or wrong but there is always a place for improvement ;)

Link to comment
Share on other sites

Now that is the elegance I was looking for. I still have a lot to read but I tried out the $child->children->count and it worked like a charm. Thank you extremely very much fbg13. Today I learned a lot and I will be using this in the approach to my main page. I tried both count options and they gave the same result so it is good to know. I guess I can pass some extra parameters: $child->children->count(blabla=blabla) to return count result that match the results in the brackets. Am I guessing right?

Link to comment
Share on other sites

Adrian, thanks for pointing that out. What you say makes perfect sense and seems to be even shorter sollution. I tested that out as well and it worked like a charm. Well noted for the future use. I just did not realize that the $child is already a result of $page->child so counting the number of the children as you propose would return the correct value.

I am extremely grateful to all of you who are sharing the knowledge and assisting me not to go the slippery road sometimes ;)

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...