Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed last year.
Improve this question
I am currently upgrading an application that was using a combination of PHP serving content and Angular JS to Angular 13 with a PHP back end.
There are two things that I am struggling to find a solution to so if anyone could point me in the right direction I would be really greatful
My exising app uses a custom framework based on PHP, the Angular Templates were loaded from a PHP script. This allowed me to create a class that dealt with the HTML so for example I would have a Form object that you could add bootstrap rows and columns to, and in turn add objects to the columns.
The php code would be something like the below which has been simplified
$form = new form('id','class','submit function')
$bsrow= $form->add(new bsRow());
$col= $bsrow->add(new bsCol(2,4,6));
$col->add(new button('id','class','caption','action');
echo $form->getHTML;`
The advantages of this were that if ever the button class changes I simply modified the HTML. More handy for widgets than buttons but it meant that all buttons were formed in the same way.
The other advantage of this is that I can read the captions from an XML file that the customer can override allowing them to change button text, styles etc. It also allowed me to embed logic on the server end to change the way the application behaved using php based on a config file.
So Question 1:
Now that Angular is all HTML and each component has free hand HTML I seem to have lost that ability. Is there anything in Angular 13 that I can use to allow me to create these templates? Is that what a directive is meant for? It seems they work differently in IO to JS. The directive would need to be able to be set up as single element (such as a button) or a container (such as a form or div) that can accept child components.
Question 2:
As the existing customisation was done on the server is there something I can use to load a set of customer configurable setting from a file somewhere that doesnt get blatted every time there is a new build. For example an application setting to alter the routes or a set of custom definitions that specifies the element ID and the custom text to use.
Question 3:
How do you allow the customer to set their own set of style overrides?
Hope that makes sense.
Php doesn't fit well in rendering Single Page Applications. When SPAs were not in trend, the backend used to process a request & return the corresponding HTML.
But, with SPAs & frameworks like Angular, once we load the index.html file, everything happens on the browser now. We render, navigate & manage the application state in the browser. For communicating with the Backend, we make HTTP requests using SOAP/REST APIs & then manipulate the DOM accordingly.
Answer to a few questions of yours:
Is there anything in Angular 13 that I can use to allow me to create
these templates?
With Angular, you can create components that can be reused throughout the application. You can read more about the concepts like Content Projection, View Encapsulation, TemplateRefs, ViewChild. For creating reusable & scalable components, you can follow Atomic design pattern. https://cfpb.github.io/consumerfinance.gov/atomic-structure/
Also, you can take advantage of CSS preprocessors like SASS that has features like mixins & placeholders for creating reusable styling.
Is there something I can use to load a set of customer configurable
setting from a file somewhere that doesnt get blatted every time there
is a new build
You should save all the customer configurable settings on your Backend. Whenever angular application loads, you can fetch these settings in APP_INITIALIZER just before your Angular app bootstraps & gets rendered on the browser.
How do you allow the customer to set their own set of style overrides?
No idea about how your earlier setup used to work but with Angular, you need to setup a framework/architecture for this. You would fetch the customer preferred styles as a JSON object & use it to update styles of your components dynamically. Here are common ways to change styles dynamically https://medium.com/swlh/6-ways-to-dynamically-style-angular-components-b43e037852fa
Related
Hello I'm here for counseling as I'm currently re-designing my website to add a user-interface which will allow me to edit it's architecture and content anywhere and whenever I want.
(I know there is already CMS or Frameworks made to ease the development but I'm trying to learn the "how to" and methods of development before jumping that step.)
I designed my website stylesheet using SASS/Compass which output me a clean CSS file. In this css I have some icons classes generated using SASS loop, they have the same attributes but the background.
$icon-list: aftereffect, photoshop, illustrator;
#each $icon in $icon-list {
.#{$icon} {
background-image: url("../icons/JPEG/#{$icon}.jpg");
}
}
The "$icon-list"s content which was static is now stored in a table to be dynamic, I wish to add and remove entries freely without manually editing and producing again and again.
So my question here is : How can I do to generate the icon classes only when there is an update in the icon's table ? What's the best way to do it ?
Those are the two mains solution I came with:
I think it's possible to compile SCSS with PHP, I could edit the icon's SCSS file, then replace the $icon-list variable's content and compile scss whenever I'd issue an add/remove request with php on the icon table. But I'm not too sure of how to do it.
Always when an add/remove request would be issued, I could generate the new icons classes with php and stack them to the bottom of the main stylesheet. But then I'd have to search and remove the previous classes, because It wouldn't erase the previous styles and I wish to keep only one css file.
I hope you will be able to help and counsel me on which methods are the best and if you have a better way to do it. I'm not asking for snippets of code because I really wish to develop myself and learn but If there is a need for it, to explain something then be it. I'm really sorry for seeming exigent and for my bad english as I'm not a native speaker.
Thank you.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am planing to build a simple CMS (with PHP) for my own educational needs and I ran into a problem with design as I have never encountered this in any book or tutorial.
If I wanted to let used mess around the colors for example. How do I do that? The only idea I had was make a database with basically all such a options and then echo them to the site as normal CSS. But thet would mean it would load from DB every single time someone visits the webasite. It seems to me like it could overload the website. But again, I have never encountered such a problem. Or is there a way of doing this much more easily?
Thanks for every answer!
EDIT:
I would like to create a system that enables user to change css via CMS. For example background color, drop-down menu colors, text sizes, fonts and a lot of other stuff handeled by CSS. Simple customization.
So I was asking 2 questions.
How? What system should I use? No book/tutorial I read never covered editing CSS files using PHP so I have no idea how to do that. Or maybe there are better ways of doing it?
I had idea how I would store all customisable data. In database I wanted to know how big it can be and whether it would be a problem when posibly tens or maybe even houndreds of variables would be loading to the site.
EDIT2:
And btw I never worked with Wordpress or other CMS and I kind of expected that options like what I am looking for are present there, is that true? In my mind such a feature is essential for user inexperienced with computers. But from what I understand from link provided by Sam (http://css-tricks.com/css-variables-with-php/), it's not common. It's actually quite complicated thing and might harm performance of the website.
I hope I made my question clear now.
I know this has tons of downvotes, but you can cache your database queries. You can also mimic a CSS file using the header type in PHP. See http://css-tricks.com/css-variables-with-php/
This will allow the browser to cache the CSS file that was generated by PHP & MySQL. This means the database will only be called when the cache expires.
In terms of size you will never reach a limit with what you are describing.
Update
These sort of features are a bit unorthodox, using a cached version of the generated CSS file is basically mandatory.
What you can do is include a text editor within the CMS to edit the CSS file, each user can have their own CSS file that overrides the default one if changed. By letting them edit it directly they can change the layout themselves. You can even limit them to only changing colours / font-sizes etc.
I have a dating site which is currently in English language.
As per client requirement he told me to convert the website in Polish language.
If I will create language file for the website, then I need to rework on whole project.
Is there any technique so that my website is automatically translated into Polish language when it is loading in browser. There also some hidden div's that will be displayed when a specific event occurs.
The website is created in php with smarty templating.
Please help me for this.
Thanks
If you want a custom solution, you're going to have to do some editing of your current code.
Option 1
Store all your strings in YAML files or within a database, or flat file, or however else you want them stored. The fact of the matter is that, as soon as your application loads, it'll query the database for the strings in your language (your url will have /en, /fr, /de etc at the end) and place those onto your page.
This means you'll have to code the retrieval of this data, and placement within your application.
Option 2
Use Google's "Auto Translate" as per Dainis' suggestion in the comments. This isn't as customisable, but means you don't have to do any reworking of your current code.
Option 3
Use Bing's translate API and manually request strings for the data you want translated on each request. Access to the Bing API is free for developers and has loads of free translations included - but this will be data intensive unless you cache the translations for future use.
With Option 3, you'll still have to code your own custom solution. So if you're on a tight deadline or you're just plain lazy, go with Option 2.
I'm trying to develop a invoice printing module for the application we're creating (in PHP & Javascript). The thing is... I want our clients to be able to customise their invoice output as in being able to choose where to put their logo and header, how to organize their data output, etc.
I know how I want to do it, but what I don't know is how to put it into practice, so my question is: is there any Javascript or PHP class/module providing an editable canvas/layout? (so I can allow my customers to custom design their documents or reports).
Something being able to handle <div></div> blocks in a graphical way, similar to what tag editors do, returning a serialized array or something like that... well, anything would actually do, as long as I'm able to integrate it in our codebase, but that's the question...
I couldn't find anything like what you are looking for but it shouldn't be too hard to create one.
I wouldn't go for a canvas based solution but rather on an absolutely positioned DIVs with drag and drop functionality and inline content editing.
You can easily serialize the content and position of the DIVs using Ajax.
The tutorial here is not what you are lookign for but it's the first step in the way: http://devheart.org/articles/jquery-customizable-layout-using-drag-and-drop/
update
Obviously this: http://jqueryui.com/demos/draggable/ is also an important reference
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
OK I'll try again, sorry if it's too simple for you; we all have to start somewhere.
I need to use a webpage to specify the layout of the newspaper ie header, footer and news areas. This is produced by an HTML page which I have created [the one with check boxes and a create button].
A second web page is to add content to the various components; again, I have the HTML page with 3 sections for input to the header, body, and footer, each with a save button. The content then needs to be output.
The information is to be stored in a MySQL database, but I only need to use the web forms I have already created in HTML to design the layout and add content. The database is to store the layout and content information.
Changes to the database tables should dynamically reflect changes in the presentation page.
The database I have already created has 6 linked tables so far [layout, header, footer, local,national and international]. I also know the MySQL code to link with the database, but not how to code to POST information to the database from the web pages via php handling to the database or GET information from the database.
Can anyone help?
What I've learnt so far:
If you create a CMS you'll gain tons of programming experience.
If you want to build a news portal for a real client avoid [1] and use an existing CMS.
Although there are a number of frameworks and cms's systems that you could use. The php commands you are looking for to interact with the database you will find here.
http://ca2.php.net/manual/en/function.mysql-query.php
I hope this helps.
It sounds like you are reinventing the while, and all the problems that will come long with it. May I suggest you use an existing CMS? There are a myriad of options, but some of the more famous that come to mind include...
Plone
Joomla
Drupal
TYPO3
WordPress
There is even a wikipedia page on the subject: Web content management systems
I am actually working on a similar project. Dont use an existing CMS... most cms are overkill for something this basic... It also gives you more control over everything and it is a great way for a beginner to learn PHP and how to work with databases... One tool I have found helpful is FCKeditor... It allows the client to create a detailed layout just as if they were using Word but will return HTML to you...
Look into:
drupal
wordpress
As starting points. Good luck.
I have had success using WordPress in this fashion and would recommend it.
This post was helpful to me doing something similar:
http://blueprintds.com/2008/03/13/top-10-wordpress-cms-plugins/
As far as composing a page with separate content sections there are several approaches to take. Here are 2 common ones.
Approach 1: Make your theme's page or index template pull the content from separate "pages" or "posts". Choosing the section to include based on either categories you set on the "page" or "post" meant to display in that section or a customfield value indicating they are to be displayed in a section. I like this approach cause you get the nice html wysiwyg editor and versioning for the content.
Example of template:
html
<? php /*call main pagecontent*/ ?>
html
<?php /*call 2nd section of pagecontent (posts where category = '2nd section' limit 1)*/ ?>
more html
<?php /*call 3rd section of pagecontent (posts where category = '3rd section' limit 1)*/ ?>
etc
Approach 2: Use custom fields for the separate content sections for a single post (number of disadvantages here but it might be more straightforward to get something quickly.)
If more detail is desired for the above let me know.
I'm doing something similar for a client. Because of deadlines and budgets I gave up and have to use an existing CMS. That is my advice for you on this project. But I'm sure you will continue to develop this CMS either on the side or for the project anyway so what you'll need to do is in addition to connecting to the database you'll just create a function to call data from the correct table. You use SQL syntax within a PHP function and you'll say pull content FROM tablename WHERE table column=correct row for the page. The guy who linked to the PHP manual sent you to the right page.
I must say developing your own CMS is not a bad idea like a lot of people keep saying for a number of reasons.
1. You learn a lot in the process
2. Many cms's have tons of overkill.
3. While they're all overkill they miss one important feature and thats content blocks. Pages may need more than one editable content area. Wordpress and the like only allow you one main section of the page to edit. Sure, they have dynamic sidebars and menus but that's not what we're looking for. We need a CMS that allows you to edit a handful of different content areas of a page. I'm creating my own CMS for just this purpose. I'm having problems separating the code in such a way that I can just call functions within different page templates bu that's another story. Anyway, use the info in that PHP manual link. I think that's exactly what you're looking for. In the meantime don't give up on that CMS and don't listen to everyone who says that the world doesn't need yet another one. It does. A barebones one that pulls more than one main content area from a DB into a page. That's all. No plugins, no overkill. Just chunks of content. Maybe share your source code when you're done so some people can learn?