Jump to content

New Template Method: Does this make sense to do it this way?


joer80
 Share

Recommended Posts

Let me know if you think this will work, and would be a good idea of a way to layout my website and templates.

The idea/end goal is you could download the this profile and build a website without touching a line of code.  php or css.

To build the website, you would just create templates in the backend that do not use their own template file, but use the alternate template file setting of main100.php, main50-50.php or main75-25.php depending on what you want to create.  (That tells the system how many rows you want to use and what size they are.)

The profile would also come with extra fields you can use.  (Mostly repeaters.)  Next, you would add those fields and repeaters to template files you create.  (Each repeater would be a row on your website, and you can drag and drop the row order by editing your templates.)

The main template files the website comes with run a "makerows" function in them in certain areas.  ie.  main100.php runs makerows('header') and makerows('content'), while main75-25.php runs those and also makerows('sidebar').  They also run a makeJS function at the bottom of the page, and import a merged.css file in the head area.

The profile would also have a folder that organizes the row code snippets based on where they are suppose to print, and that variable I am passing in the makeRows function would be the location of that snippet.  Default options are: content, sidebar, header, footer.

The example folder structure for the content snippets is:

bootstrap/

bootstrap/content

bootstrap/sidebar

bootstrap/header

bootstrap/footer

bootstrap/header/pageTitle

bootstrap/header/sliderRow

bootstrap/header/ParalaxRow

Each row folder would have 1-3 files in them, and an optional /images/ sub folder maybe?

bootstrap/header/pageTitle/code.php

bootstrap/header/pageTitle/style.php (Optional)

bootstrap/header/pageTitle/js.php (Optional)

The code.php file would have the html markup for the row and the php variables in it placed where they need to be, style.php has all css styles used in this row, and js would have any javascript this row needs. (I did style as a php file so you could use variables for the colors, but the website merges it into a .css file automatically.)

I have a page in my admin backend that when ran, it will loop through each subfolder in my bootstrap folder, and read each style.php file in each folder, and build out a merged.css file in my template directory.   That is why my main templates never call a css function, they just import the merged file.

When the page you are on loads and calls the makerow function, it just loops through all repeaters tied to the current page you are on for that location you passed, ie. header, content, sidebar.  It then checks for a snippet named that same way.  ie.  A sliderRow repeater on your page would look for the sliderRow folder, and include the code.php file in that folder.  

What do you think?  Or is this not a good approach?

I have it working, but I am also wondering if there was a way to assign a default alternate template filename of main100.php to each template the user adds? Or would there be a better way to have their templates that holds the repeaters separate from the main templates that just set the columns they want?

Thanks!

Link to comment
Share on other sites

Well i would prepare the rows in advance before i knew anything about the project using the css and html and they would just put it together and choose images to make the website. That may be different than what you experienced.

Link to comment
Share on other sites

Dynamically build js/css files per single site neglect the purpose of client site caching, which would result in poor performance especially on first visits. Also this sounds quite complex just to stitch together some images and text. In my experience most of my clients even don't want that much control over the layout as long as they can change the content.

  • Like 1
Link to comment
Share on other sites

The css and js is not stiched on page load of a regular template. It is a page that doesnt run much in the admin section side. Or you could call it when a template is edited in admin. No need to stitch for a user view.

The purpose is not for the clients to design the website, but a graphics person that can not program that would help launch websites for clients.

It sounds complicated because we are talking the under the hood inner workings. It wouldnt be bad to use. Most things are complicated when you look at the code.

Link to comment
Share on other sites

@joer80 - sounds interesting, and i support the idea of some profiles that have configurable things like page layouts, widgets, etc..

I've done some similar things as you are speaking about, in order to create a reusable profile, and we'll see how it goes once i start reusing some of these..

been looking at this the last day or so..

http://designmodo.com/startup/

Link to comment
Share on other sites

not sure, i haven't gotten as far as you on this.. I mostly use fields on the editor to define layouts, like page table, or page table extended; and i use global widgets with lister pro, or page specific widgets with an enhanced page select..

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...