Jump to content

Bootstrap 4 Minimal site profile


flydev

Recommended Posts

Bootstrap-4 Minimal site profile for ProcessWire

This profile is based on the "minimal site profile (intermediate edition)" and bundled with Boostrap v4.4.1

 

  Features

  • Bootstrap SASS
  • Font-Awesome SASS
  • Render / helper functions for :
    • Simple ul navigation
    • Bootstrap Multi-level navbar
    • Bootstrap Carousel
    • Bootstrap Cards
    • Bootstrap Jumbotron
    • Boostrap Accordion
  • Assets minification, files bundle

  Dependencies

  • jQuery
  • Popper.js
  • Bootstrap
  • FontAwesome

  Prequisites

 You'll want to install the following on your system before proceeding:

How To Install

  1. Download the zip file at Github or clone directly the repo with git clone and skip the step 2.
  2. Extract the folder site-pwbs4-master into a fresh ProcessWire installation root folder.
  3. During the installation of ProcessWire, choose the profile "ProcessWire Bootstrap 4 profile".

  After installation

You can find the development file (CSS/SCSS/JS) in site/assets/dev/src

The profile can be used as is only with $config->debug set to false. To use it in debug mode, you are required to install the dependencies with the package manager.

  • Open a terminal in site/assets/dev and execute the following command-line: yarn

Available commands :

  • Rebuild, minify and bundle assets for release : yarn build

  References

  Credits

  • The ProcessWire staff
  • Inspiration from @gebeer and his Bootstrap 3 profile post
  • Members who contributed in various post about Bootstrap navigation and code (see code-source for refs).

Screenshots

1467976435_Annotation2020-01-12095634.thumb.png.2ce0b184edcaaccd16ba2f309291501a.png

Edited by flydev ??
New version - 2.0.0
  • Like 12
Link to comment
Share on other sites

Thanks for doing this and will start working with this one this week-end. Really excited about it if this one can release me from using Pocketgrid all the time. Did you know that there is a thread about templates for Processwire ?

https://processwire.com/talk/topic/12892-processwire-marketplace/

This bootstrap profile could be a very good one to start with.

  • Like 2
Link to comment
Share on other sites

@pwired :   I will send an email to @kongondo about processwireshop.pw! Thanks for suggesting that.

----

A small trick to make the navbar/dropdown working on mouseover instead of click event:

In js/script.js add :

$(document).ready(function(){
    $('ul.nav li.dropdown').hover(function() {
        $(this).find('.dropdown-menu').first().stop(true, true).delay(200).fadeIn(200);
    }, function() {
        $(this).find('.dropdown-menu').first().stop(true, true).delay(200).fadeOut(200);
    });
});
  • Like 2
Link to comment
Share on other sites

Is there anything that has to be compiled before using this template ? For example until now I only use plane css and not sass also never used "bower-install" Maybe there is a pre-compiled version ?

Link to comment
Share on other sites

In the current state of the profile, Bootstrap is already precompiled in css/styles.css; You can also find in the folder css a file called main.css where you can override all values and use it as pure css - without the need of using sass and associated tools - but at this point  you still need Bower.

Bower is used to manage assets like font-awesome and a dependency like tether in our case. With this tool we can manage libs easily and we can avoid repeating tasks. It is really easy to install and do not require any knowledge for the task we accomplish here. If you want to get started with, check the following instructions :

  1. goto https://nodejs.org/ ,  download / install NodeJS
  2. install Git (if you're on Windows, be sure to check Run Git from command-prompt)
  3. open a terminal and type npm install -g bower

done.

You can now execute the bower install command-line.

 

Anyway, if its really required, I can make tonight a profile with precompiled files so you can test it this week-end :). Just let me know.

 

  • Like 1
Link to comment
Share on other sites


Hi @flydev,
Thanks for stepping in on this. I am not yet familiar with node and git and use processwire with plane php, api, css and pocketgrid. So Yes I would appreciate it for making a profile with precompiled files to enable me start using your template. Thanks in advance.

Link to comment
Share on other sites

I have setup an online test server and uploaded/installed the pre-compiled profile (template) inside a processwire 2.7.2 setup. It looks everything is working well and also nicely responsive. I find this great. I am going to have a look in the back and front end and see how I can change it into some website and learn bootstrap and tether. You can see the online setup here: http://dev9.pe.hu

 

  • Like 3
Link to comment
Share on other sites

Thanks you for trying this profile.

I just pushed an update to the css for the responsive menu. Just remove the following code in main.css.

Spoiler

/* meanmenu adjustment (see body: line-height) */
.mean-nav ul li {
    line-height: 24px;
}
.mean-container .mean-nav ul li a.mean-expand {
    height: 24px;
}

 

 

  • Like 3
Link to comment
Share on other sites

@flydev Thanks a lot for putting this together. I was only waiting for BS4 to reach beta state before I will update my site-pwbs profile. Now I don't need to spend the time on it myself, which is great :)

@pwired @cstevensjr

I can only recommend to preprocess yourself and encourage you to look into node, compass, bower etc. It really is worth the effort and gives you so much more flexibility. With the precompiled version of this profile, you need to override a lot of stuff in your own CSS and this will bloat your code.

  • Like 3
Link to comment
Share on other sites

9 minutes ago, gebeer said:v

@pwired @cstevensjr

I can only recommend to preprocess yourself and encourage you to look into node, compass, bower etc. It really is worth the effort and gives you so much more flexibility. With the precompiled version of this profile, you need to override a lot of stuff in your own CSS and this will bloat your code.

While I agree with you that one needs to expand their horizons, we also need to understand that not everyone uses the latest technology.  We should strive to make these profiles accessible to everyone, no matter their knowledge/skill level.

My push will always be about accessibility to technology by all.  I firmly believe that's how things will spread.

  • Like 3
Link to comment
Share on other sites

Just now, gebeer said:

@cstevensjr I partly agree with you. And again thanks to @flydev for providing the precompiled version. But in a way this defeats the purpose of a sass based site profile.

You seem to be stuck on sass and I am talking about having PW profiles that a basic beginner (who may or may not know anything about sass) can utilize.  We are coming together from two totally different planes.  Yes, I believe it was fantastic and a good trend that @flydev augmented the profiles by including the precompiled version.  It should be a great learning tool for all.

  • Like 4
Link to comment
Share on other sites

  • 2 weeks later...

Thank you Flydev. I've spent several days looking for proper solution to the PW BS3 dropdown menu issue. And then today I've found this. This profile will be my based from now onward. So far it works good, looking forward to build something great out of this. Once again TQVM.   

  • Like 4
Link to comment
Share on other sites

  • 7 months later...

Hi @MaryMatlow

15 hours ago, MaryMatlow said:

I've installed it and it works fine.

Can you please tell me the version of ProcessWire ?

 

15 hours ago, MaryMatlow said:

Is there a way to add heading and link to the images?

Yes, you have to copy and/or modify the function bsRenderCarousel();

For instance, you could use a repeater to pass datas to the function. Let's say we create a repeater with the three following fields: image_carousel, heading, heading_description

Capture.PNG

and insert the repeater with the name 'carousel' in the home template.

 

In _func.php, add this function :

Spoiler

function bsRenderCarouselFromArray(array $datas) {

    $cnt = count($datas['images']);
    $id = $datas['images'][0]->get('page').$datas['images'][0]->get('field')->id;
    $out  = "<div id='carousel-{$id}' class='carousel slide' data-ride='carousel'>
                <ol class='carousel-indicators hidden-sm-down'>";
    $i = 0;
    foreach($datas as $image) {
        $class = ($i == 0) ? "active" : "";
        $out .= "<li data-target='#carousel-{$id}' data-slide-to='{$i}' class='{$class}'></li>";
        $i++;
        if($i >= $cnt) break;
    }
    $out .= "</ol>
             <div class='carousel-inner' role='listbox'>";
    $i = 0;

    foreach($datas as $data) {
        $class = ($i == 0) ? "active" : "";
        $out .= "<div class='carousel-item $class'>
                <img src='{$datas['images'][$i]->url}' alt='{$datas['images'][$i]->description}' height='{$datas['images'][$i]->height}' width='{$datas['images'][$i]->width}'>
                <div class='carousel-caption'>
                    <h3>{$datas['headings'][$i]}</h3>
                    <p>{$datas['description'][$i]}</p>
                </div>
             </div>";
        $i++;
        if($i >= $cnt) break;
    }
    $out .= "</div>";
    $out .= "<a class='left carousel-control' href='#carousel-{$id}' role='button' data-slide='prev'>
                <span class='icon-prev' aria-hidden='true'></span>
                <span class='sr-only'>Previous</span>
             </a>
             <a class='right carousel-control' href='#carousel-{$id}' role='button' data-slide='next'>
                <span class='icon-next fa fa-chevron-right ' aria-hidden='true'></span>
                <span class='sr-only'>Next</span>
            </a>
        </div>";

    return $out;
}

a bit hacky but eh...

 

Then in the home template, make the array and call the new function with the new array as parameter :

// render the carousel
//$content .= bsRenderCarousel($page->images);
foreach ($page->carousel as $key => $value) {
    $datas['images'][] = $value->carousel_image;
    $datas['headings'][] = $value->heading;
    $datas['description'][] = $value->heading_description;
}

$content .= bsRenderCarouselFromArray($datas);

 

Result:

pwbs4.gif

 

 

  • Like 4
Link to comment
Share on other sites

  • 5 months later...

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
×
×
  • Create New...