| Project: | ProjectPier |
| Version: | 0.8.8-alpha |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | phpfreak |
| Status: | closed - fixed |
Jump to:
Whilst cleaning up layout code for Kamp Pro 2 (https://github.com/dbernar1/kampPro2), I decided to validate the code. Besides my own errors, it said that practically all links were causing errors, because the ampersands in them weren't escaped like `&`.
My proposed solution is to borrow the HtmlHelper from CakePHP, and instead of allowing an associative array for a link, allow the paramters for `get_url` (in an array) to be allowed
## Usage:
`$html->link([string $title], mixed $target, [array $options])`;
### $target
Either an array, i.e.
`array('access', 'forgot_password')`, which will be internally translated to `get_url('access', 'forgot_password')`;
or a string
$tabbed_navigation_item->getUrl();
### $options
used for the attributes of the created a-element, i.e.
`$Html->link('title', '#', array('id'=> 'foo', 'class' => 'bar'));` becomes `title`
My apologies for the lack of formatting, I was experiencing issues at first. Then after logging out I forgot to change the input format.
Why borrow such a class? Can we simply reuse it like that or do we need to give credits somewhere?
Why not simply fix the get_url function?
EDIT: I fixed the get_url function in application/functions.php
from this
return with_slash(ROOT_URL) . 'index.php?' . implode('&', $url_params) . $anchor;to this
return with_slash(ROOT_URL) . 'index.php?' . implode('&', $url_params) . $anchor;All ampersand validation errors on the login page went away when using the W3C validator.
I installed the Chrome Validator Add On and fixed already a number of pages. Most pages look good after the fix above.
...
Indeed an easier solution, hadn't even thought about it myself.