Jump to content

Learn & Launch project


MilenKo
 Share

Recommended Posts

On 18.12.2016 at 8:43 PM, MilenKo said:

Btw, I have noticed something strange - quite a lot of PW users are either Russians or germans. In youtube, I found two series of videos with how-to theme PW and they were both either on German or on English but done by German. Is there any specific reason for this fact, or it just happened to be like it?

You are not the only one, who noticed that. :lol:

If you are already using delayed output, you should check out the new region function, if you haven't already. It comes in really handy. ;)

  • Like 1
Link to comment
Share on other sites

AndZyk, I wish I have studied German now knowing that youtube has some gorgeous PW series about how to do everything :) Thanks for the region function. It looks really cool and would help me better define the variables so that they does not overlap in my projects. Being a newbie means that sometimes I use variables that can fit the purpose, however, it is not a rare case to match purposes in different areas and has issues that would be hard to troubleshoot without the proper knowledge, tools etc.

Link to comment
Share on other sites

Ok, so I worked today on the News template and I can say that so far I had no issues. I just noticed a strange mistake I made where the image of the inner pages was not showing. The issue was caused by an attempt to assign a variable for the inner page images by $child->image, where it was already described earlier, was not the right call. The code that shows properly the image and inserts the alt is this:

<img src="<?php echo $page->image->url . $page->image;?>" alt="<?php echo $page->title;?>" width="600" height="480" class="entry-thumbnail" />

Another challenge was to make the date format in the inner pages appear as it is in the template (it is different in Articles and News listings, where in Articles shows N-days ago, but News shows the month day, year format). Here is the call I used to make it match 100%:

News-inner:

<time datetime="<?php echo date('Y-j-d, G:i', $page->created); ?>"><?php echo date('F j, Y', $page->created); ?></time>

For the articles-inner, I did not add it yet but would use the same structure with just playing with the php date function and matching the appearance. Once done, I will share it with the rest of the progress.

I have not yet determined what would be the next step as it might have some challenges - the search functionality with the dropdown box for searching within specific child pages or the comments. Most likely I will start implying the search in order to be able to start adding real content and searching for it. Any tips, tricks, ideas and so forth would be highly appreciated (as always). What I will be trying to implement is a good ajax search that would show some results or can search for any, or etc. Let's see how easy it is to make a search with PW. So far I am extremely pleased with the functionality so hopefully the rest of the theme won't change my mind ;)

 

 

Link to comment
Share on other sites

On 15/12/2016 at 10:33 AM, Robin S said:

$logo = $pages->get("/")->logo->url . $pages->get("/")->logo;

On 15/12/2016 at 5:05 AM, MilenKo said:

$image = $page->image->url . $page->image;

15 hours ago, MilenKo said:

<img src="<?php echo $page->image->url . $page->image;?>" alt="<?php echo $page->title;?>" width="600" height="480" class="entry-thumbnail" />

This is not the right way to get the url of a single image.

When using image fields you want to select the "Formatted value" setting that suits the number of images your field is allowed to hold.

2016-12-22_091843.png

I recommend you stick to two of these options:

  • Array of items - select this when "Maximum files allowed" is set to either 0 (no limit) or greater than 1
  • Single item - select this when "Maximum files allowed" is set to 1

Next you need to understand what is going to be returned when you use $page->image (assuming your image field is named 'image'). If you chose "single item" then $page->image will be a single image object. If you chose "array of items" then $page->image will be an array of image objects. You don't want to ever echo an object itself (it may return some value but it's generally not good practice), but you might echo some property of the object (e.g. description) or call some method on the object (e.g. url or size).

When dealing with an array of image objects you will either loop over them with foreach or you can get a single object from the array with a method such as first() or eq().

So take this code example from above:

On 15/12/2016 at 5:05 AM, MilenKo said:

$image = $page->image->url . $page->image;

You want to get the URL of a single image in the field. If your image field is formatted as "single item" then you would do this:

$image = $page->image->url;

If your image field is formatted as "array of items" then you would do this:

$image = $page->image->first()->url;

 

One more thing...

15 hours ago, MilenKo said:

<img src="<?php echo $page->image->url . $page->image;?>" alt="<?php echo $page->title;?>" width="600" height="480" class="entry-thumbnail" />

You are setting width and height attributes on the img tag so you should use the size() method to make sure the image is cropped to the same dimensions (or same ratio of dimensions if you are wanting a HiDPI image).

$page->image->size(600,480)->url

Otherwise you wont get the desired result if someone uploads an image with a different aspect ratio.

  • Like 5
Link to comment
Share on other sites

Just wanted to add, that an image has also an width, height and description property. So you could output it like this:

$thumbnail = $page->image->size(600,480);
echo "<img class='entry-thumbnail' src='{$thumbnail->url}' width='{$thumbnail->width}' height='{$thumbnail->height}' alt='{$thumbnail->description}'>";

So you don't have to change the width and height attribute manually. ;)

  • Like 3
Link to comment
Share on other sites

Woow.. Something good is going to come out of the Launch and learn :) Thank you Robin S and AndZyk for the useful corrections and the bonus info provided. Will start "fixing" the stuff to make the proper calls and then after finishing will move to the next step - the search.

I see that New Zealand is also proud to have ProcessWire Masters ;)

Link to comment
Share on other sites

On 12/21/2016 at 4:27 PM, AndZyk said:

Just wanted to add, that an image has also an width, height and description property. So you could output it like this:


$thumbnail = $page->image->size(600,480);
echo "<img class='entry-thumbnail' src='{$thumbnail->url}' width='{$thumbnail->width}' height='{$thumbnail->height}' alt='{$thumbnail->description}'>";

So you don't have to change the width and height attribute manually. ;)

 

AndZyk, I have tried to implement your suggestion as it looked much much clear and easy to digest, however it seems like PW is not thinking the same way. Here is the result when I inserted your code in the place of the image:

Fatal error: Exception: Method Pageimages::size does not exist or is not callable in this context (in C:\OpenServer\domains\nowknow.pw\wire\core\Wire.php line 476) #0 C:\OpenServer\domains\nowknow.pw\wire\core\WireArray.php(2163): ProcessWire\Wire->___callUnknown('size', Array) #1 [internal function]: ProcessWire\WireArray->___callUnknown('size', Array) #2 C:\OpenServer\domains\nowknow.pw\wire\core\Wire.php(374): call_user_func_array(Array, Array) #3 C:\OpenServer\domains\nowknow.pw\wire\core\WireHooks.php(549): ProcessWire\Wire->_callMethod('___callUnknown', Array) #4 C:\OpenServer\domains\nowknow.pw\wire\core\Wire.php(399): ProcessWire\WireHooks->runHooks(Object(ProcessWire\Pageimages), 'callUnknown', Array) #5 C:\OpenServer\domains\nowknow.pw\wire\core\Wire.php(402): ProcessWire\Wire->__call('callUnknown', Array) #6 C:\OpenServer\domains\nowknow.pw\wire\core\Wire.php(402): ProcessWire\Pageimages->callUnknown('size', Array) #7 C:\OpenServer\domains\nowknow.pw\site\assets\cache\FileCompiler\site\templates\news-inner.php(25): ProcessWire\Wire->__call('size', Array) #8 

and quite a few similar lines.

Seems like it is unhappy to pass the thumbnail size. Any suggestions/ideas?

Link to comment
Share on other sites

$thumbnail = $page->image->first()->size(600,480);

Although if I have an images field that is named to sound like a single image, eg "image" then I always make sure to set the max to 1, rather than 0 so I don't get confused about whether it's going to be a single image or an array.

  • Like 1
Link to comment
Share on other sites

Adrian, your code did the trick perfectly.

To be honest, at the beginning I created an image field and assigned it to the logo and anywhere else an image is needed, however, these days I decided to split them as somewhere I might need to allow a single image, somewhere an array, have different requirements for empty field etc. It won't hurt if you have a few different image fields, eg. logo, body_image, background or anything else. At least it does not make any template heavier...

I will redo the images call everywhere now and move on.

Thanks again, adrian for the suggestions and feedback. The reason I think PW is my final stop is that the community is GREAT!!!

  • Like 1
Link to comment
Share on other sites

1 minute ago, MilenKo said:

Thanks again, adrian for the suggestions and feedback. The reason I think PW is my final stop is that the community is GREAT!!!

No problem at all - glad you decided to stick around - it's nice to have some more Canucks here!

  • Like 1
Link to comment
Share on other sites

Hahah, Canucks I guess you call me because of the Canadian location of residence? I am not really Canadian even though I live here for a long time. Originally I am from a small sunny country located on the Black Sea Coast called Bulgaria ;) But, no offense taken at all...

  • Like 1
Link to comment
Share on other sites

Ok. Now it is time to move on to the search functionality. I am presently looking at skyscrapers to see how is done the search there. Should not be that difficult but will see. Any suggestions, ideas, warnings etc. are more than welcome. The difficulty for me would be to make it work with the drop down list of a child where the Articles, News and FAQ's are added as well as add another criteria - the page format (video, image, text). It's time for fun guys...

Link to comment
Share on other sites

Hello, everyone. I had a tiny bit of spare time and decided to play a bit with PW. Opening up the page to see if everything so far is working fine, I noticed that the logo is appearing OK on the main (Home) page but on the inner pages it shows a missing image. I remembered that I changed the $page->image->url call that was suggested earlier and did not check if the logo appears. The problem with the logo on the inner pages was caused by the fact that a simple $page->logo-url call would not work on templates where the logo is not added as a field. Considering the fact that in every template I am including the header.inc where the header logo is, I started to think how on Earth the trick is working. A bit of digging and brainstorming and the solution is in place. I added to _init.php the logo variable and changed the call in header.php:

$logoURL = $pages->get('/')->logo->url();

As far as my idea is at the end to move most of the settings to a specific "Settings" page, then I will have to change the page where the logo will be kept, however this won't be a problem when I have the reminder of what was done and how in here.

Happy holidays and Merry Christmas lovely and super supportive people. All the best and tons of productive ideas in 2017 ;) (that would make our life even easier and nicer using PW :) )

  • Like 2
Link to comment
Share on other sites

Hello again. A bit of spare time in between the Christmas and New Year parties was used to start working on the search. Having looked at the skyscrapers example and the needs of the theme I use for my project, I realized that to accomplish the search and fit into the theme I would need to add another field to the Articles, News and FAQ templates which would be the post type with a list (text, image/s, video). This was needed as in my search form I have the choice to select the page category (Articles, News, FAQ or Any) as well as the format of the post. I know based on my experience that this functions might not be needed as far as the search results show some results based on any word in any order in the title but it is the theme that decided to do it that way and the idea here is to have an example how it is done if needed.

Here is the sample code to list the "Category" and some thoughts about it:

<select name="category" class="form-control">
	<option value=''>Any</option>
	<?php 
	// generate a range of all the FAQ types, checking our whitelist to see if any are already selected
	foreach(array('FAQ', 'Articles', 'News') as $range) {
		$selected = $range == $input->whitelist->category ? " selected='selected'" : '';
		echo "<option$selected value='$range'>$range</option>";
	}
	?>
</select>

So far I used just a simple array to list my options as all I did not create initially the Articles, News, and Faq to be under some main template so that I can call a list of the child. I might redo the structure for the later use in order to allow the listing of other categories added on the fly but so far I am trying to achieve the basic functionality and then would work on the improvements. What is not clear to me is te $input->whitelist->category ? Does the 'whitelist' is a part of the skyscrapers theme functions or is a call in PW for the checkup?

Of course following the analogy, my format call is like this:

<select name="format" class="form-control">
	<option value=''>-- All Formats --</option>
	<?php 
	// generate a range of all the FAQ types, checking our whitelist to see if any are already selected
	foreach(array('Text', 'Image', 'Video') as $range) {
		$selected = $range == $input->whitelist->format ? " selected='selected'" : '';
		echo "<option$selected value='$range'>$range</option>";
	}
	?>
</select>

The game continues...

Link to comment
Share on other sites

Oops, nevermind guys, I found the answer for $input->whitelist by a simple search. I should have checked the code before. Here it is the explanation just in case someone else is looking at the code and wondering why on Earth it is used.

Now would be the time to create a search template to list the results of the search. For this purpose I would need to either use the Article listing or News listing but the decision is yet to be determined ;)

Link to comment
Share on other sites

Happy New 2017 Year my favorite community of PW. All the best wishes goes to devs of this fabulous Symbiotic Organism (if I may allow myself to call PW like that). The idea behind this is that it grows with every new 'cell' joining the community, it evolves surely in its DNA and the changes happen most of the time rapidly right in front of our eyes. For me as a newbie in the web development and using PW it is so much fun as I am learning a lot and by the time I memorize it, there is already a better and much more elegant approach.

But enough of the sweet talk, I still have my goals to achieve and convince myself how easy it can be achieved once the knowledge gets on the way. I'll be honest and admit that so far I was doing some development in short sparks of 10-15 minutes break time so most of the functionality was achieved with a snap of the fingers. Now it is time to implement one of the most important functions to my theme - the search and I would lie if I don't say that I am expecting some struggle and a fight here. The reason to start learning was to make the site search working as we need it at work (mostly used for intranet Knowledge database and not stop only there but to continue improving the functionality based on the expanding needs in time. Looking at first at the theme - I would not even hope to reach that far so PW was like a little Christmas gift for me wrapped with the help and support of all others who knew what/how and did not mind sharing it.

Like all crazy people do, we started redecorating and painting our house a few days before Christmas where we had to cook and host a party for the new year celebration so I decided that today is my "day off" from everything where I would lie in bed and do nothing. Well of course I came up with a better idea - to use all my spare time to implement the search at least and document it well in the forms and code so that I can always come back to it and know why I did it that way etc. I saw a few people had some struggling with the search functionality however I am planning to look at the skyscrapers and the default examples and figure it out.

So let's cut the good memories of the party and start working out the 2017 ;) I saw this morning Ryan's post and got excited even further so am planning to test his latest release to use as a 'search dissection' ;)

Link to comment
Share on other sites

Ok. I think there should not be any issues with the search even though I did not have much time playing with PW even though I planned to. Instead of giving explanations, I will just copy/paste the simple search code with some comments in it to help me and everyone else the logic:

Spoiler

<?php

include("./includes/header.inc"); ?>

<div id='content'>

	<?php

	// look for a GET variable named 'q' and sanitize it
	$q = $sanitizer->text($input->get->q); 

	// did $q have anything in it?
	if($q) { 

		// Sanitize for placement within a selector string. This is important for any 
		// values that you plan to bundle in a selector string like we are doing here.
		$q = $sanitizer->selectorValue($q); 

		// Search the title and body fields for our query text.
		// Limit the results to 50 pages. 
		$selector = "title|body~=$q, limit=20"; 

		// If user has access to admin pages, lets exclude them from the search results.
		// Note that 2 is the ID of the admin page, so this excludes all results that have
		// that page as one of the parents/ancestors. This isn't necessary if the user 
		// doesn't have access to view admin pages. So it's not technically necessary to
		// have this here, but we thought it might be a good way to introduce has_parent.
		if($user->isLoggedin()) $selector .= ", has_parent!=2"; 

		// Find pages that match the selector
		$matches = $pages->find($selector); 

		// did we find any matches? ...
		if($matches->count) {

			// we found matches
			echo "<h2>Found $matches->count page(s) matching your query:</h2>";
			
			// output navigation for them (see TIP below)
			echo "<ul class='nav'>"; //This can be replaced with the wrapping div of the search results etc.

			foreach($matches as $match) {
				echo "<li><a href='$match->url'>$match->title</a>"; //This lines to be replaced with the styled appearance for the search results
				echo "<div class='summary'>$match->summary</div></li>"; // as per the theme styling
			}

			echo "</ul>";
			
			// TIP: you could replace everything from the <ul class='nav'> above
			// all the way to here, with just this: renderNav($matches); 

		} else {
			// we didn't find any
			echo "<h2>Sorry, no results were found.</h2>"; // This can be replaced with the content we want to show if no matching is found
		}

	} else {
		// no search terms provided
		echo "<h2>Please enter a search term in the search box (upper right corner)</h2>"; // This can be replaced with content for a search call without terms
	}

	?>

</div><!-- end content -->

<?php include("./includes/footer.inc"); ?>

 

 

I am certain that this would make the search results showing properly, however looking back at the code of the skyscrapers I have found the logic behind the delayed output so I think it might be the perfect timing for me to work a bit on the existing theme files and redo them as per that. I had difficulty understanding the calls and what was the full logic of it, however, I found out that every template defines the content of $content or $body (just variables that can be named anything) so the main template is showing just $content/$body instead of the full logic of the specific template. I might do the simple search first and then start improving the site so will see but what is more important is that the code above makes perfect sense and represents the easy implementation I was so afraid of messing up.

Once I finish with the code, I will post the search.php in case someone would need to review it. As far as my example is of a premium theme, I am not sure of the consequences posting the code in here, so I will have a look to another free bootstrap theme that would have most (if not more) of the functionality already discussed and will post the files/theme once done. If you happen to like the premium theme and want to turn it into a project, I will do my best to share the needed pieces of the code to achieve that so that you would already have the rest ;)

  • Like 2
Link to comment
Share on other sites

OK. I think I found the victim of choice that might have even better functionality, however, what is more important - it is fully free so I can use and share the files with everyone. The official theme is for Wordpress so I will have to strip it to HTML code, do an initial cleanup and what is left to implement in PW. It would be exciting I think as I will try to start with the delayed output from the beginning so as usual if you find any errors or know a better approach, shoot straight.

Here is the theme in case I got your attention to it.

Once I clean up the code will share the HTML version so that we could start it together and learn on the fly ;)

Link to comment
Share on other sites

Alright. I was checking up the theme and it looks like the one I was looking at was the developers original website, so stripping that out would be also not very much liked. The theme would work in Wordpress and would be free, however I need to setup wordpress, add categories, follow tons of instructions just so that I can strip the code etc. Will have to choose another theme that would be Bootstrap/HTML5, fully validated (it is important to make sure that the final result would also be valid ;) ) and what is most important - to be free with no obligations and if possible - to be a knowledge share. As far as this theme hunt would be long and will move the focus away, I will just look for a good looking valid bootstrap theme that would have some complexity and start with it. For sure I will finish the one I worked on already and share as promised the key parts to make it dynamic.

Link to comment
Share on other sites

Ok. So for the moment I am back to the initial Bootstrap theme to finish what we started. As far as the search functionality offers an ability to select the page category and post type (does it contain an image, video or text), I decided that I need to add a way where the post type can be defined during the adding. Initially, I thought a list of the options would be best where the list would contain: text, image, video however I was surprised that I did not see such type in the field set. Decided to have a checkbox with the three options so that the type can be checked during adding, however, I am struggling to achieve that as well while adding a field Post_type and choosing the type as a checkbox. I am not finding a way to define the choices of the checkboxes so any ideas or suggestions how to do that? 

I have read something about creating a checkbox field as a page and add some subpages in it with no file defined for the template, however, it was not clear for me, so am still struggling to achieve the simple functionality needed.

Link to comment
Share on other sites

Ok. It was worth revisiting the instruction for the creation of the page without template (Post types). After assigning it to the template post_types (that have a title and post_type fields only) I was able to create 3 pages (Text, Image, Video) and assign them to Articles-inner, News-inner, and FAQ pages. Because of the fact that the Text, Image, and Video are children of a page, I can list them all using a simple query in the search form dropdown box. Easy as cake. So the search is on its way to being developed and implemented...

Link to comment
Share on other sites

Hello again. Today I had to become creative but I am glad to a once that the search functionality is fully completed. As I am getting back to the office and I have to present the theme to my it team, I decided to remove for the moment the drop down categories and post types as it is not even clear are we going to use it or not to share the company knowledge internally. I did not remove the post types as I realized that I will need that to show a different icon before the post title (image, text or video).

Once I get back home I will share my search.php and the search form I used in order to make everything work. As always, feel free to share any spotted mistakes or if you know a better approach. To achieve the search functionality, I got the code from PW standard profile and defined the $out to be equal to my result code. I had some issues assigning html code to a phone variable, however after an hour of coding and fixing silly errors it all came as it should.

Now when the search is done I think it is time to start importing some real Hortons and add the categories (parrent/child) in order to show the data on the main page.

 

Link to comment
Share on other sites

Ok. I had to fine tune some of the possible search errors, so I added the code and error message if no results are found as well as if a search is initiated without keywords etc. Here is the code used of the search.php and search-form.php, so please do not spare the mercy and share honestly if you see something that can be improved in the code.

In order to implement the search you need to create add the template using search.php and then create a page (I called it Search Results, as I used the title in the headline) which use search template.

As far as the needed functionality so far is achieved with the search, I am moving forward starting to create some real howtos and group them in the proper parents that would be shown on the main page. I am not expecting to have difficulties doing that as the API seems pretty straight forward even for my non-programmers brain but if something comes up on the road, will search for a way to solve it. 

As per szabesz advice (thanks for the idea), I am adding the code in a spoiler block. So here is the content of search.php:

Spoiler

<?php

/**
 * Search template
 *
 */

$out = '';

if($q = $sanitizer->selectorValue($input->get->q)) {

	// Send our sanitized query 'q' variable to the whitelist where it will be
	// picked up and echoed in the search box by the head.inc file.
	$input->whitelist('q', $q); 

	// Search the title, body and sidebar fields for our query text.
	// Limit the results to 50 pages. 
	// Exclude results that use the 'admin' template. 
	$matches = $pages->find("title|body~=$q, limit=10");  

	$count = count($matches); 

	if($count) {
		
		$found = "Found $count articles containing text <strong class='text-danger'>\"$q\"</strong>";

		foreach($matches as $m) {
			
			$date = date('Y-j-d, G:i', $m->created);
			$relative = wireRelativeTimeStr($m->created);
			$cat_link = $m->rootParent->url;
			$cat_title = $m->rootParent->title;
			
			//Search result header block
			$out .= "<article class='hentry'>" .
					"<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='{$m->url}' rel='bookmark'>{$m->title}</a></h2>" .
					"</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='$date'>$relative</time>" .
					"</span>" .
					"<span class='category'><i class='fa fa-folder-open-o fa-fw'></i> <a href='$cat_link'>$cat_title</a></span>" .
					"</div>" .
					"</footer>" . 
					"</article>";
		}

	} else {
		$found = "There are no records found in the database...";
		$out .= "</article>I am sorry for the inconvenience, however no matter how hard I tried digging deep in my database, there were no matches found matching <strong class='text-danger'>'$q'</strong> as a keyword. Maybe you could try to refine the search terms and try me again? <p><br />Another option would be to write down an <strong class='text-danger'>article, faq or news</strong> on the topic yourself so that the next search comes with a positive result <i class='fa fa-smile-o fa-1'></i></p>";
	}
	} else {
		$found = "I am missing a search term in the search box...";
		$out .= "</article>In order to allow me to search the database and find some useful stuff I need to have some <strong class='text-danger'>search terms</strong>. Otherwise it would be just a pointless waste of mine and your time trying to pull some articles that are not important for your goals!";
}

// Note that we stored our output in $out before printing it because we wanted to execute
// the search before including the header template. This is because the header template 
// displays the current search query in the search box (via the $input->whitelist) and 
// we wanted to make sure we had that setup before including the header template. 

include ('./includes/header.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 $found;?></p>
							</blockquote><!-- .archive-description -->
							
							<div class="archive-list archive-article">

								<?php echo $out; ?>

							</div><!-- .archive-list -->

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

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

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

 

 
 
 

And here is the code for the search-form.php: 

Spoiler

<form action="<?php echo $config->urls->root?>search/" method="get" class="search-form" role="search">
	<div class="form-border">

		<div class="form-inline">
			<div class="form-group">
				<input type="text" name="q" value="<?php echo htmlentities($input->whitelist('q'), ENT_QUOTES, 'UTF-8'); ?>" class="search-field form-control input-lg" title="Enter search term" placeholder="Have a question? Type your search term here..." />
			</div>
			<button type="submit" class="search-submit btn btn-custom btn-lg pull-right">Search</button>
		</div>

	</div>
</form>

 

 
 
 
  • Like 2
Link to comment
Share on other sites

@szabesz , I started the sharing as code, however, it went too long, so I changed it to an attachment. Looking at the spoiler block now->makes it look much much better and for sure if searchable would make more use of the code ;) 

This morning I started to think how to group the Articles, News and FAQ and thought to create a parent called Howtos however I need to attach a template to it and I do not really need/want this to be browsable but just to separate the howto pages from the rest. At first I thought that I can assign a template from the Articles or News however that would duplicate the content (it would contain all articles, news and faq in one list). As I expected it caused error in the articles.php template, where I use the code for the pagination:

Spoiler

<div class="archive-list archive-article">

	<?php if($page->numChildren) {
			$result = $page->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 -->

 

 
 
 
2

I wanted to group the articles, news and faq pages at first place just sp that I can grab the list of every child in Howtos parent and show it on the front page where a few posts from each one are shown. On the other hand, if I need to allow access to a colleague to add content than it would just be done by providing it only to the Howtos page and any child pages in it. Any ideas how to better organize the structure if you think my approach is not needed/the best following the logic?

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