PHP Form builder class working with old version of bootstrap? - php

I am using the php form builder class (http://www.imavex.com/pfbc3.x-php5/examples/html5.php)
and jqbootstrapvalidation (http://reactiveraven.github.io/jqBootstrapValidation/)
So far I can succesfully combine these (even using some of the patterns php form builder class already built in) and I edited some of the element php files to change a pattern here and there, and to add some \n's to make a readable source code. (I still don't like my entire form on a single line in the source..)
But I would like to use different colours for the bootstrap. I've tried downloading several themed bootstrap.min.css files using paintstrapand twitter bootstrap themeroller
However, as soon as I include these instead of the standard netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css file, all my styling is lost and it looks the same as if there was no stylesheet included.
Since the php form builder class is relatively old, do I need to change all it's code to become compatible with the newer bootstrap, or is there a faster way to do this (perhaps a different form builder?)? Or am I messing up something else that is causing this change style options?

Appearantly there are a few changes need to make to fix this:
https://code.google.com/p/php-form-builder-class/issues/detail?id=205
allthough it is not "full-on" bootstrap 3.0. Also, the jqueryvalidator needs some adaptation to work with bootstrap 3.0. I'm currently busy making everything work the way I like it, adding glyphicons for the forms (optionally) etcetera. I'll get back to you as soon as I am finished and drop the code of somewhere for all the lovely people to enjoy or shout at.

I did'nt want to use imavex class for several reasons :
wanted a class witch could be easily updated if Bootstrap's version changed
wanted to have more control on generated code (add or remove wrappers, class, attributes, ...)
wanted to generate separate code for css/js includes/js code
wanted to be able to configure any jquery plugin with it
So I made my own (not free but only 5$), you can see the demo and complete doc here : http://codecanyon.net/item/php-form-class-for-bootstrap/8790160?WT.ac=category_thumb&WT.z_author=migli
Hope it helps and hope you'll like it

Related

Would it be possible to create your own semantic markup "<something></something>" for you template engine in PHP?

I would really appreciate if anybody could help me with this question :)
I want to know whether it's possible to create your own semantic markup in PHP, just like BB Codes, but I want to be able to use it within my template engine system, so I could use it to call custom modules like voting system, adding comments, login form, registration form and so on...
Let me make it clearer for you guys of how I mean;
I'm working on my own CMS not to use it for production purposes but to learn PHP in a better way;
So I had this idea to call specific modules in a page based on their position and in order to be able to do;
For instance we're having a login module which is simply a login form, nothing too crazy, however you want to be able to include that module dynamically in any page you want using the backend and not touching any code;
So all you do in the template page is using my bb codes that I told you earlier;
Something like this;
Remember this is only an idea;
<zone name="left_sidebar"></zone>
And you add this zone markup on your sidebar and if any of your module supposed to be displayed on your left sidebar, it will just by having this markup and nothing more...
And you gone have loads of these semantic markups based on how many editable blocks you have on your page; so you could have one for the right sidebar, one for footer and one for header... etc.
So I now need to know how to could lookup for opening and closing tags, in this case it would be <zone></zone> , then it need to lookup for its attribute and its value, in this case name="right_sidevar"
....
Anybody have any idea of how I could possibly do this kind of thing...
Thanks in advance :)
You could check out TWIG; while it doesn't directly support this kind of feature (because it uses a special syntax for its own elements) it does have very good support for making your own elements, tags, sub-applications and other funky things in the backend.
http://twig.sensiolabs.org/
There are also a number of systems that perform this kind of task in the front-end; this would mean that the substitution is done by Javascript in the browser. In addition to the already mentioned Polymer, there's also Google's framework, Angular.
https://angularjs.org/
Maybe you can use php's libxml module to parse your xml file.

Extend, modify, or override Joomla's bootstrap.php?

So I've been playing with Joomla 3 with Bootstrap. At first I didn't fully understand what they meant by Bootstrap being baked into the CMS - seems like you could call it but would have to either use Javascript or template overrides to match the expected output. Not much more convenient than calling the Bootstrap framework manually.
Then I found a few links about libraries/cms/html/bootstrap.php - and there was much rejoicing:
http://doc.joomladev.eu/api3/Joomla-Libraries/HTML/JHtmlBootstrap.html;
https://groups.google.com/group/joomla-dev-cms/browse_thread/thread/59ede023a635cc78/18f67450a08e66ff?lnk=raot;
http://itprism.com/blog/106-bootstrap-tabs-accordion-slides.
This seems to be a work in progress, and the limited links I found indicate that there are some kinks to be worked out. But useful for going forward...especially if I can create or edit my own as needed.
Is there a way of using this file in a template override, like modules.php?
Is there any better documentation than what I listed above?
Thanks!
As a JHtml helper, you would use it like any other JHtml call you see in the CMS. As you probably know, JHtml::_('behavior.framework'); enables MooTools in the CMS. Well, there's a similar function JHtml::_('bootstrap.framework'); that will load the Bootstrap JavaScript as well as its jQuery dependency. So, if you want to enable Bootstrap's alert plugin, just call JHtml::_('bootstrap.alert', 'optionalClassNameForAlertElements'); and you're all set.
Bootstrap has less than a year in the CMS while MooTools has been around for a while, so obviously the support can still be improved upon. But, we've tried to make it easy to quickly enable the various Bootstrap JavaScript plugins so you can focus on front-end work.

Bespoke PHP Templating Engine

As a small part of a university project I'm working on (custom MVC based project management system), I need to develop a template engine. I don't wish to use an off the self system such as Smarty because I've written every other part of the project myself and don't want to go back on that now.
Anyway, I've managed to code something simple so far, I have a class, create an instance of it, add some data to the instance, then pass in a template file. The file has a series of tags like {this} when then get replaced with the data. Simple.
The issue I'm having is when it comes to looping things - i.e. a table of users or a list of categories. At the moment I have a template file for the page (users.html) which contains the opening and closing tags, with a template tag between them called {users}. I then have another template file (users-detail.html) which displays a table row with the user info in. I'm creating a new instance of the users-detail.html template, adding the data, parsing it, then placing the output (string of HTML) into an array. I then loop this array, attach all the strings together, then assign this to the {users} tag in the users.html template file.
As you can probably tell from that explanation it is a bit of a bodge, and there are probably better methods out there for doing what I'm trying to achieve. Ideally I want to avoid using PHP in the template files if possible, and I often need to have multiple loops within one template file.
If anyone has any tips / advice on how I can achieve this, or any tutorials I could follow to get some inspiration that would be much appreciated.
Thanks in advance.
I've seen that approach before (including another template for the insides of loops). I used to work on an old version of vbulletin which does (or did) this. It makes things annoyingly complicated because you can't just add a loop to a template - without setting up a whole new template for each layer of looping.
I'd advise you instead to go along the route of Smarty.
Classically, this statement:
I don't wish to use an off the self system such as Smarty because I've written every other part of the project myself and don't want to go back on that now.
... indicates you really should just be using Smarty. In the real world that would be a poor justification for re-implementing something yourself. But I am like you, and I understand that you want to implement something yourself (because you want to learn, you find it fun, you are a perfectionist, etc). As long as you do it on your own time and it's a personal project, go for it.
It would be worth studying Smarty to see how it works (not just the syntax but how it compiles templates, stores the compiled version etc). Are you comfortable writing a tokeniser/parser in PHP which can compile your template language and output PHP? If you are advanced enough to do it, do it. At the very simplest, you read in a tag like {foreach from=$something} and somehow translate it to <?php foreach ($something as $thing) { ?>. You check token types, etc to make sure the template tag is valid, and so on.

A client wants me to do CSS coding (only) but doesn't want to provide me the php files

I have a client who wants me to do CSS coding only, but doesn't want to give me the php files.
Right now, I just have access to the live website (with no CSS).
It is entirely made with tables and I want to use divs instead
I'm not sure if it is possible to do the coding
I thought about copying and pasting the generated HTML code from each page
Will this cause possible problems with the end result?
Yes, this will cause huge problems: you'll do an awesome job, client will have trouble integrating it with their site, client will abandon your awesome work.
IMO, you should let the client know that you'll do the best you can with what they have given you, but you would be able to save them a lot of work and do a better job if you could have access to the source code.
If you know that you can't make the client happy with what they have given you, though, it would be doing everyone a disservice for you to try.
If you absolutely can't convince them to give you access to the source, then this client sounds stupid:
He has a layout which is table based.
He wants you to magically make it look better with CSS, without having access to the source.
"#Phoenix I don't see any classes or IDs." - there are no classes or ids to hook into.
You might be able to do it if you used some CSS3 selectors to, for example, select the 3rd td inside a td inside the 2nd table to apply styles to ;)
But, that won't help if you have to support older browsers, which makes this impossible at the moment without doing something differently.
I don't have full knowledge of your situation, but here's what I would probably do (if I couldn't convince them to give me access to the source):
Open the live site.
Copy the HTML source code.
Paste it into a new local file.
Add this into the <head> section: <base href="http://the-clients-site.com/" />.
This will let all the assets on the page load from the client's actual site.
Now, you have something to work with.
You have to keep track of ALL changes you make to the file.
The first change should be adding your own blank style tag.
Then, you can add id and class to whichever elements you feel need it.
You should try to avoid moving around elements, unless it's absolutely required. Those changes are a whole lot harder to explain to someone. I know from experience.
You should be able to style the page properly now.
Then, you deliver the completed page, and the documented list of changes you had to make to the HTML (add id, here add class there).
The client should then be able to integrate the changes into his site.
Well, at a bare minimum they'll need to modify ther PHP to reference your CSS. More importantly, you need to be able to hook your CS up to elements - Do tables/rows/etc. have Ids or classes attached?
If they are clever and have some good separation between code and presentation (using a templating engine or similar) then you can probably just edit the template / css.
If they won't let you edit the PHP and you come up with a new awesome layout, they will have a nightmare job trying to integrate it and probably won't bother.
I don't see the problem. You can style tables just as easily as divs. You don't have to know how the wall is built to know how to paint it, which is pretty much all you've been hired to do. Only problem I could see would be if they haven't added any classes or ids to the elements yet. After all, what the browser/client sees is the only thing that needs styling, and since you can see everything that the browser sees, you can see everything that needs styling.
If they have added classes/ids, then just take a copy of a page and style it in a testing area, and then once it looks nice, you take a copy of another page and make sure it looks nice with it too, add to the CSS if there are any new unstyled elements that didn't exist on the first page, once it looks nice, then move on to another page, and another repeating the process until you are satisfied that it appears that every page within reason would look nice with it.
If they haven't added classes/ids, tell them they need to in some capacity before you can work on it, perhaps provide some guidance on the issue.
I'm actually doing this right now for SO.
I'm working on a userscript that provides an alternate "clean" stylesheet for the StackExchange network. I have no access to the SO engine. I am using the Chrome Inspector to look at how the elements are set up. I recommend the same. (Although it is a little different, since I'm modifying the original CSS file.)
You can easily identify what you want to style with the Inspector and then work from there. I would suggest that you ask your client for a list of classes and IDs though. (I got that in the form of an existing stylesheet, you can go about it in a different way, if that suits you and your client.)

Mediawiki - Using PHP inside a form or page

I need to use some PHP code inside of a MediaWiki form. Basically, I need to use some PHP date stuff and create a few infoboxes based on timeframes. Is there a way to use PHP to generate a "template" in the "edit" box?
I'm very new to developing with MediaWiki, so I'm not sure how MediaWiki exactly works, and this is a very small project, so I haven't really dived into any documentation for the most part.
You can certainly add secure HTML within a wiki page. It seems there is also a securePHP extension. I haven't tried the PHP one myself but the HTML one works very well.
I was able to do this myself with a MediaWiki plugin called SemanticForms:
SemanticForms

Categories