Jump to content
Joss

How to create a simple news system for PW

Recommended Posts

If you wish, but did you read the images documentation I pointed you to?

If you have an image field, you can grab the image and then, by using the size function, you can create a thumbnail. This will produce a resized image on loading the page. The new version of the image is stored with the size as part of the file name.

$page->image-field->size(100,100)->url 

That creates the thumbnail and gets the url.

So, to create a thumbnail that is clickable for the full sized image. I have overwritten it a bit to make it clear.

<?php
echo "<a href='{$page->image-field->url}' >";
echo "<img src='{$page->image-field->size(100,100)->url}' >";
echo "</a>";
?>

As you can see, the size command is used to produce a thumbnail 100x100. You can also use the width command to define the width only.

It is all in the images documentation, including all the other parameters you can use to control image quality and so on.

  • Like 1

Share this post


Link to post
Share on other sites

 I tried a few ways but not getting enough. 

Okay, please let us know what you have tried and maybe someone can help you resolve your issue.   The forum members are eager to help, you just need to provide some detailed information about what it is that you want to achieve.  You would be surprised how much can get done, when we all work together.

  • Like 3

Share this post


Link to post
Share on other sites

Beginner profile means its just fill dummy data when install PW, nothing else. Btw, too sad not much documentation for simple requirements like thumbnail grab for pages. I tried a few ways but not getting enough. Seems like I should  stick on with concrete 5 :(:'(

Welcome to PW and the forums @JeevanisM :-)

The link @Joss pointed you to has exactly what you want...i.e., creating thumbnail grab for pages..see under 'Resizing Images'...

foreach($page->images as $image) {
 $large = $image->width(500);
 $thumb = $image->size(100, 100);
 echo "<a href='$large->url'><img src='$thumb->url'></a>";
}

Whilst there's still need for better documentation, we certainly don't lack documentation about the basics...the stuff that will get you up and running with ProcessWire...I know it can be confusing at first but ProcessWire is really easy...

A bit OT but as a beginner, I personally wouldn't install ProcessWire with a site profile unless I have first read up on how the different site profiles work (tutorials section in the docs). Why am I saying this? Because they contain some functions that really have nothing to do with ProcessWire but are helper functions created to suit those profiles that may confuse you (especially if you don't know what's coming from where). For instance, the renderNav() function you've pointed to. That is not part of ProcessWire but just a helper function created in those profiles. Instead, I would install ProcessWire without a site profile (aka the blank profile), create a blank template file in my favourite text editor and on my second monitor (if you have one :-)) open the ProcessWire docs about $page and $pages and start playing. Just plain PHP...no CSS and JS . Once I got the basics is when I'd start thinking about displaying cute DIVs :-).

Sorry if I sound brash...just typing in a hurry...+ above is my personal opinion...'horses for courses'...they say..And if you've already gone through the docs, apologies...ignore me... :-)

Whatever your learning style, I hope you stay with ProcessWire. I promise you the benefits (once you get over the initial hurdle) far outweigh the initial pain of adjusting to a new system, especially one in which you have to type a bit of code :-)

PS; Don't let my post put you off from asking questions, mind...

  • Like 6

Share this post


Link to post
Share on other sites

To make a site with ProcessWire you will have to do work a bit more than that. The documentation is there, and it's very complete, but it won't teach you sokething that specific. You will have to join the pieces of the puzzle yourself. It's totally worth it though, once you learned by yourself how to list your articles with the thumbnails, you wil know how to do anything you want. And I mean anything! No code examples as I'm on mobile, sorry.

  • Like 3

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...