System for generating websites - templates

I searched...can't find any good references. I have what I think is a pretty simple question: What are the basic concepts behind a system that allows customers to specify and generate a website, from a choice of style templates?
Say for example I created a simple website consisting of four static HTML pages. I can make those pages look like anything I want by using different CSS templates...good.
But if I wanted to give my clients an interface that says "hit this button and your site will be generated" -- I don't know what the basics are underneath that idea to make it happen. Is it simply a matter of creating the directories and copying files?
Before I go down a dumb path I just need some general guidance about how this type of thing is usually done. There are notable services out there that offer people the ability to sign up for an account, and in "three easy steps" generate a simple website. I want to learn the theory and basics behind how that is done.
Thanks...
EDIT:
I know how to change an existing set of static HTML pages using CSS. What I want to do is build a true website generator. You log into my system, pick a theme, hit a button and your site (e.g. www.foo.com or foo.parentsite.com) is ready to use. I can figure out how to allow customers to change content -- by integrating tinyMCE for example. I just need the basic concepts behind the "hit a button...generate a new site" idea.

You can change with javascript the css used. This will change the looks of the current page.
But you need to make multiple css with an unique look.
I suggest you to make a generic css and add the theme of your site into a small css.
The small one should contain only what is unique with this theme.
generic.css => Place content,menu, footer, etc...
theme1.css => Change background color to red, change text color to blue, etc
theme2.css => Change background color to blue, change text color to blue, etc
theme3.css => Change background color to blue, change text color to red, etc
JQuery Ui allow to change his interface easily.
Check this and change selected gallery on left
I don't think you can generate an website than customer will be very satisfy.
There's always something than client want to change.
EDIT:
You need to create folder on the server.
Put all necessary file with his selected themes into the folder
Configure apache for his domain. Then reload it for the new config.
I suggest you to use PHP or cgi.
The thing I don't know how is to register the domain if available and how to redirect his domain to your ip easily and automated.

Found something else tonight: There is a full set of APIs that can be used to gain access to cPanel functionality. So, almost literally, using their PHP wrapper it looks like only a few lines of code to instantiate a subdomain, set up email accounts, domain pointers, etc.
Looks promising...but being a total noob I have a lot of reading to do...

Related

aurelia pages with different page formats

In the Aurelia SPA template it assumes that every page will be inside app.html and use the same nav-bar at the top. But I'll have many pages that don't want the nav-bar at the top and actually not use app.html at all. I was looking at main.js and it looks like I could hook into bootstrap() and change the aurelia.setRoot() for certain pages (I'm just guessing here), but then I start mucking up the main.js file and it won't be long before it gets really messy and maintenance headache. I really just want to have some pages use their own format altogether and ignore the app.html formatting without doing any crazy configurations.
My initial thought is maybe app.html should just be an empty file and make every page decide whether or not it wants the nav-bar and include it on the individual pages. But now I'm duplicating the code across many pages and if the standard page layout changes I have to change all the individual pages. Not sure the best way to go about his. Any suggestions?
I actually disagree with Gilbert's answer. Using .setRoot is a best practice; the root is just the parent view/viewModel pair and you will often have different parents. This is essentially what you're doing when you're creating an empty app view/viewModel, creating a new parent that doesn't do anything. But adding an unnecessary, unused layer is just extra complication.
One of the best use cases for this is a login page. The login page is totally different from your normal app page--there's a login prompt, no navigation bar, etc. Therefore, make a "login" app root and a "app" app root and switch back and forth between them. I've built a template called Sentry that demonstrates how to do this.
Sentry in action
Sentry on GitHub
Using set root, like you said, is a bad idea. Similar to what you said, you can make app.html contain just the router view tag. Different parts of your app, that you want to share a similar page layout, will be gruped under different routes. Now each of theses routes will point to another router that will have its different styles in the view
Just think of it as an empty app.html with child app.html's that have styles in them(e.g. Different navbars, page layout etc)

Opencart different .TPL for the Home Page

I have a doubt and not really sure about how is the best approach, I have a client with a website based on opencart with really bad practices on it, for example, all products are manually placed in the home page instead to be using the CMS capabilities of OC, right now the way it works is, if you are using a computer, full browser, the site displays the full version of the site, but if you are using an ipad or iphone/android device then loads the "small" version, both versions are placed manually in the same home.tpl document and they appear/disappear by some CSS. The question is, the client doesn't want to change the way the home page is designed, so instead to be loading that enormity of code is there a way to have a different tpl for the small version? for example a home.tpl version with the code for the full version and home-mobile.tpl for the small one? how this should work? How the system should determine the screen size and point to a TPL or other TPL?
I know it's a weird request but the client is "happy" with how the site looks like and don't want to change the manual code used on the home page.
CSS is the correct way to handle the resizing and restructuring of the same content on different screens. If you want a vastly different homepage for mobile users, with different content, there are a couple of ways to do it:
Detect the browser using JS and redirect to a mobile-only page. This would probably involve copying your current home controller (and template etc.) to a new file, or using a GET variable to switch templates further down the code.
Detect the browser using PHP, and serve the correct template directly in the code. For this you could use a library like this one (untested, just an example) in your home controller, and change the template path as needed at the bottom of the script.
But first I would really try harder to emphasise to your client that he is doing it wrong.

Adding Template Select and Image upload to custom post in Wordpress

I have become a bit confused on the best way to move forward with something I'd like to achieve in Wordpress. My problem is partly workflow I think and knowing the correct way to do what I'd like to achieve but also there may be a few blanks on how to actually implement some of what I need to do. I have checked various online resources but they all are specific to what they are doing and I can't easily understand them to apply them in to the context of my own project, which is why I wanted to ask here. I'm sure my initial question will inevitably branch out to sub questions but here we go:
For my website I have created a custom post type called 'projects'. I have successfully set this up.
Then for each project I need to allow the following data to be entered:
Project Title
Project Description
Also post meta data that will display as a list on each project page (I'll need to display both the key and value on the page but only for those fields that contain data 'i.e. I don't want the list to show as Location: blank'):
Client Name:
Location:
Project Value:
Architect:
Engineer:
Site Area:
My main question is this, I need to show images for each project and allow the user to select a 'template' for each project post, this is because there are about 5 grid designs for layout of the images (1 main Image, 1 square image with two small images right side, 3 portrait image cols etc).
I thought the correct way would be to create a custom post type called projects, add write panels to allow easy input of data (I've yet to add image uploads as this will need to vary depending on the template selected and number of images required), at data input stage the user selects the preferred image layout/template and then uploads images for the containers that allow images (I’ll need to id each image upload to position it in the template with CSS, that was the plan).
Firstly, am I approaching this correctly? And secondly, how can I add functionality to the write panel I have created to allow users to a) select a 'Template' (bit like you can with pages but for my custom post type) and b) to add image upload fields which change depending on the template selected?
Finally, I would like to stay away from using plug-ins and try and achieve this myself through functions.php etc. This is to avoid problems later as plugins update or lose support etc.
Any help is appreciated, thank you.
This sort of question seems to come up a lot in regards to Wordpress (I answered essentially the same question the other day). I know you want to avoid plugins but this sounds like a job for Advanced Custom Fields.
You can create exactly the fields you need for your custom post type (including an image upload field), and then add them into the template the corresponds with your custom post type.
ACF does have a 'lite mode' which can be included directly in a theme. This way you needn't worry about updates nuking site functionality. Believe me you will save yourself a lot of time and energy this way.
It's admirable to try and do it with pure WP, but it's a maturing platform, it just doesn't lend itself to this sort of customization easily.

Opencart module development - Inject javascript/html code in some pages

I'm a beginner on Opencart and just started developing a module for Opencart which it must inject some lines of javascript and html code in these pages:
- Cart Page
- Product Page
- Confirmation Order Page
- Register form page
The official documentation doesn't have informations about how can i do that, I've tried to find a good documentation about OpenCart but I didn't find anything.
I need help. How can I do that?
Diggin necro topics;) :
The easiest way i think:
upload/catalog/view/theme/[themename]/template/product/product.tpl - here you can add your custom html for product page
[your theme name, you shouldnt overwrite default theme because it can cause damage after update]
It depends on where you're trying to insert the HTML/JavaScript.
Doing things the proper way in OpenCart, you're limited to the column-left, column-right, content-top, and content-bottom positions.
The files you'll need to create are:
admin/controller/module/mymodule.php
admin/language/english/module/mymodule.php
admin/view/template/module/mymodule.tpl
catalog/controller/module/mymodule.php
catalog/language/module/mymodule.php
catalog/view/theme/default/module/mymodule.php
To learn how to do this the first time, it's easiest to replicate an existing stock OpenCart module (preferably a simple one, such as information). Once you've replicated it you'll need to go through each of those files and replace any references to "information" with "mymodule".
After that, if you've done it properly, you should be able to navigate to Admin > Extensions > Modules and see your module in there. Then install it, use the "Add module" button to position the module on all the relevant layouts, hit save and hey presto you have a working module on the front-end.
To modify the front-end output, just edit catalog/view/theme/default/module/mymodule.php
If you want to insert your HTML somewhere other than the 4 available positions OpenCart gives you, position your module in the content-bottom position and use JavaScript/jQuery to inject some HTML where you want.
If this is for your own personal website then as Pawel S suggested it would be easiest to simply modify the relevant view files (ie. catalog/view/theme/[themename]/template/product/product.tpl), however if you're making a module which you plan to distribute then this should be a last resort.
Hope that helps!
I realize this is probably long dead by now, but if you're creating a module that needs to modify existing controllers, languages, models or views the correct tool to use is vQMod.
vQMod allows you to modify existing code on the fly using XML.
https://code.google.com/p/vqmod/

How can I change the current language that users see for a Sitecore site?

Let's say I have a web site that is translated in to two languages - English and Spanish. I want to give the users a toggle switch at the top of the page that allows them to switch back and forth between the two languages. How would I do that? I don't want to set up different websites. I only want one website. I just want the user to be able to click on a button or link or something and go from English to Spanish. Now as they move around the site they are viewing the entire site in Spanish. Then if they click on the button or link again they would go back to English. Is there something I have to do in the code behind to tell Sitecore to "use" a different language?
You can switch the context language using "sc_lang" query string parameter. For example:
http://youwebsite.com?sc_lang=en
Typically in Sitecore you will want to represent the language using the built-in URL prefixes, e.g. http://www.example.com/en or http://www.example.com/es. We often use a cookie that we read in the httpRequestBegin pipeline to enhance the Sitecore LanguageResolver. Your language "toggle" could appropriately set that cookie.
See this article by John West for more detail and sample code.
https://community.sitecore.net/technical_blogs/b/sitecorejohn_blog/posts/repost-overriding-sitecore-39-s-logic-to-determine-the-context-language
You can write your own LanguageResolver Pipeline to do this.
Or you can extend your URL by Using the sc_lang querystring Parameter eg.: sc_lang=en-EN or sc_lang=de-DE. If you have configured your linkmanager fine this should work.