I am having trouble designing a solution to a complex problem. I am building a site that creates html templates including both the css files and html files. Users will be able to create multiple templates/sites.
In an attempt to create a normalized database I have a user table (id, name, email, password, etc.), a site list table (user_id, site_id, site_name, description), and the rest I am having trouble figuring out.
I am trying to develop a way to break down both the html files and css files into a database that can be used to reproduce the designed template. Constant editing and adding to the database will take place when creating/editing a template. Basically, an extremely simplified dreamweaver. Flat files may be an option as well.
Any input or suggestions on how to go about such site would be greatly appreciated such as how to break down the html and css into mysql tables/records. Im not so much looking for code, but the fundamental concepts/workings of such a site. Thanks in advance.
First of all, are you sure you even want to store that content in the database? That's going to place a heavy burden on your servers over generating them as files onto the filesystem inside the DocumentRoot and directly servable by the web server. I can see storing the configuration options (color choices, image names, etc) in the database, but not the files themselves.
Can these websites have any content the customer wants, or are they variations on a theme? If it's the former, then you really can't automate it much. You can store the content in a database instead of a file, but it won't really be advantageous.
Your best bet, I think, is to look how CMS programs like WordPress/Joomla break up a page into separate include files (header, footer, left menus, right menus, etc) and use that as a model. The customer picks a template, and each template has defined sections that can be laid out separately with different content.
You could store the templates in text files then store settings (such as CSS attributes or images they may want) in the database. That way, you just load the template with the applied settings.
Related
Ok, here's the scenario. We have a Symfony2 project and the same core code is shared by two websites, the 2nd website simply has its own App folder, with the src and vendor folders symlinked to the 'master' install. This works great and with the specific parameters in the 2nd app folder, allows us to run with a different database and thus offer the same technical solution to two companies. hurrah :)
BUT. We obviously want them styled differently via CSS, the values for which need to come out of the database. I realise we could simply code them, but with future projects in mind, we want them to be in the database and thus easy to update centrally.
So, the problem is how can we insert these database sourced values into the CSS file? I've looked into SASS etc, which would be a step in the right direction, but the values are still defined within the CSS file, not outside it.
We could do a dynamic CSS file, powered by Twig, but that's frankly using a sledgehammer to crack a nut.
Has anyone come across this problem and found a suitable answer?
I did never try it but i think that you can render a css file with Twig like you render any other file. You only have to create a route, a controller and a view.
Sorry did not read last rules..
You could add a datetime stamp in the css mysql-table. Is it changed? Render and save a new version of your css file. Otherwise skip it.
On the other hand Twig uses caching as much as posible so what is the problem?
You could create a service that write a css file in your css folder.
Call this services when you make any changes in the DB. (You can make a listener for that).
You could also use asseticBundle to manage all your css files.
I have dozens content types in which I need to display more or less block of the same fields. Using core display I have to create many groups and even than styling them with css is tricky.
My alternative is to use template suggestions but will they render faster than normal display method I'm currently using?
It will be easier to remove thoose fields from display, write the templates and render node in template (all the other data).
But how about performance?
Any help will be appreciated
Thanks
Although the answer is not so specific I would say that printing what you need in tpl.php files is faster than hidding them with css or php if conditions. So you should better use tpl.php files for each node type. And "core method" you are talking about is using tpl.php files! Look inside ROOT/modules/node folder for the tpl files of node module.
There are also some useful modules to help you with that like display suite, panels, entity_view_modes etc but if performance is a big issue you can go without them.
I have 10 different modules that are created to be used for the index page. I've created a jquery drop/sort function for the backend, so the admin of the site can change the layout of the front page without coding knowledge. However I'm having a problem finding a way to store the modules.
I have two types of modules:
1. An image, title, link and a dynamic php/mysql generated content (eg. last five reviews)
2. An image, title, link and plain text
What is the best way to store the modules that makes it possible to edit them easily in the backend? Should I store the php/mysql part in seperate php files or in mysql?
Any tips on making a good backend module solution would be appreciated.
Thanks
You should be storing your files in your filesystem, and your data in the database. That is how it is designed. You may slow things down if you put your files into the database.
Background
I'm developing my own OOP content management system in PHP for fun and to expand my programmig knowledge
What I've got
I've got the main framework set up, users can login to the backend, add pages, edit pages, set up content in rows or columns, add logo's, billboards, etc.
Expantion
My next venture is to allow users to modify the style of their website through the panel. including header colours, font size, font family, etc
How to Implement
I thought of a number of ways to do this, but i wanted to ask the community to see if they can come up with a better solution or justify one of my solutions.
Idea 1:
I could write/find a php class that parses a css style sheet, and then re-writes it as the new style sheet with the editted values
Idea 2:
I could separate the existing style sheet into structure, colors, fonts, etc, and just allow the user to modify the colors and fots separately.
Idea 3:
I could ditch the whole separating style from content idea, and make php to write the user specified styles right into the html...
Information
Does anybody have any other methods they could think of?
If not which one of mine would work best/be most efficient/optimal etc
This is not a discussion, I'm asking a specific programming question.
I understand that the panel must have an interface for the user to change the values and save their configuration in a Database OR save their configuration directly in the new css file.
I'm just not sure which way would be the "best" way.
How would 'you' do it?
I would change the stylesheets with JavaScript, like:
<link rel="stylesheet" href="somestyle.css" id="stylesheet">
function changeStyle(cssfile) {
document.getElementById('stylesheet').href = cssfile;
}
I also would enter the user's selections via AJAX into the database, so when PHP creates the next page, it knows which styles the user has selected.
I'm familiar with HTML, CSS, and some PHP and Javascript. I've made several fairly complicated websites for which I've acted as webmaster, manually adding all content in HTML.
I'm about to put in a proposal for my first outside client at a larger business. They have an IT person that would be responsible for updating the website that I create for them.
My question is what to do about content management. I've looked into things like Drupal, but they seem overly complex for this kind of situation, with a single person adding updates of things like text, images, and PDFs.
What would you recommend as the next step above the simple way of manually uploading files and editing HTML like I'm used to? Something like a MySQL database and PHP calls? Would I then store all the images in the database as well?
I guess I'm just trying to figure out what's most common at a medium-sized business. I appreciate any guidance you can offer!
Nathaniel
My company has built large scale projects and medium scale as well. What we like to do is setup a outer page with navigation and an inside page that the client has control of by a control panel with FCK Editor or TinyMCE.
So essentially we have a wrapper page (in our case a MasterPage but in PHP you would use an include or a index.php with a query string to pull the content) and then we drop in HTML content from the database.
That database is populated by the client in their control panel. FCK Editor allows them to upload images and manage links, etc.
For our bigger clients we get very specific in our control panel allowing them to add videos, PDF attachments, blog entries, FAQ content, etc.
Some examples we have are http://pspwllc.com and http://needsontime.com and http://nwacasa.org
Drupal can be bit complex at first but if you stick with the basic modules - it is great for website content management.You can write your own mini content management system - store text and images(MySQL blob format) in MySQL.It will be couple of PHP admin pages and a good render() function responsible for page rendering.
Also have a look at wordpress, it is much easier than drupal. It is less powerful but it may serve your needs. You will NOT need to configure modules like FCKeditor, with it bcoz they come inbuilt. Anybody will be able to edit the content easily. Do note that wordpress is not just for blogs, you can create different kinds of websites with it. Another choice is Joomla, it is also simpler than drupal. But, wordpress is the simplest.