Proper way to include JHTMLString class? - joomla

What is the proper way to include the class JHTMLString in Joomla 2.5?
jimport('joomla.html.html.string');
and
jimport('joomla.html.string');
doesn't work.
The only way I've managed to include this class is through:
JLoader::register('JHTMLString'), pathtotheclass);
Could this be a bug or am I missing something?

It seems like your loading it in the only, atleast atm correct way:
http://docs.joomla.org/API16:JHtmlString
Because the normal way :
http://docs.joomla.org/JHtmlString/1.6
Doesn't seem to work, and I've tested it.

A little bit late but I had the same problem on Joomla 2.5 so I had to call it like
JHtml::_('string.truncate', $text, 200);

Related

Default blade directives in Laravel/Lumen

Where can I find the default blade directives folder?
I was looking for the #forelse to take as example, but I couldn't find it.
Does anyone know where they are defined in Lumen/Laravel?
note: I'm using Lumen framework, but I think it's quite similar to Laravel in this question, so I'm tagging both.
EDIT:
Due to the imprecision, I'll explain better my intention.
Basically, I'm creating a directive exactly the same as #forelse, but with 2 or 3 further information.
For that reason, I came to ask about the location since I haven't found by myself.
They're defined in the Illuminate\View\Compilers namespace in the BladeCompiler.
See Illuminate/View/Compilers/BladeCompiler.php
Specifically you'll need the compileForelse method if that's the one you want as an example.

How to do PUT and DELETE with Zend_Http_Client

The Zend_Http_Client docs are confusing and hard to understand. Currently I am using the following code to GET information from the Challonge API:
$client = new Zend_Http_Client("https://api.challonge.com/v1/tournaments/$bracket.json");
$client->setParameterGet(array(
'api_key' => $apikey,
'include_participants' => 1,
));
$feed = $client->request()->getBody();
Very simple, three lines. Now this is a GET. How would I do the same exact thing as a PUT? Passing parameters and everything. What about a DELETE?
Sorry, I know this is not directly related to the question Json Axelrod asked, but I had a similar problem and could not find the solution anywhere online.
I was trying to do a PUT / DELETE request with Magentos Varien_Http_Client
class Varien_Http_Client extends Zend_Http_Client
So I thought the same would apply that was written in this topic and here. However no matter what I tried I could not get PUT nor DELETE requests to work.
Really simple solution in that case: Use Zend_Http_Client instead of Varien_Http_Client.
It seems that Magentos Http Client class is adding some extra "convenient" methods for preparing the body that won't allow PUT nor DELETE requests.
You would do
$client->request('POST')
or
$client->request('DELETE')

Symfony translation inside validation won't work

If I try to use translations inside validation like described here
http://inchoo.net/tools-frameworks/symfony2-translating-validator-messages/
I get always
not.blank.username
as output on Error. It seems like symfony didn't find the message-translation. I placed all my translationfiles inside app/ressources/translations and they are named as
messages.de.yml
....
What am I doing wrong? Do I have to place the translationfiles insde each Bundle?
Kind regards
EDIT: Problem ist clear and fixed, but when I try to use "MinLength" I get an strange error:
Attempted to load class "MinLength" from namespace
"Symfony\Component\Validator\Constraints" in /var/www/symfony/webprojekt/vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php line 64.
Do you need to "use" it from another namespace?
I already included
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\MinLength;
use Symfony\Component\Validator\Constraints\MaxLength;
AM I missing something?
To translate validation messages you need to create files with the following name structure inside translations folder:
validators.LANG.yml
Also, you can check in your config.yml, inside framework, if exists the translator:
framework:
translator: { fallback: %locale% }
This is required.
The accepted answer applies to using the magical default translation domain for the validator config. You can also override this in config/packages/validator.yaml
framework:
validation:
enable_annotations: true
translation_domain: 'validations'
Then in translations/ make a file validations.LANG.yaml, for example translations/validations.en.yaml. You don't need to do this but sometimes it's better to explicitly set these magical bit and know where they're coming from.

Codeigniter subfolder named like controller

I'm trying to make folder in controller folder with exact name like controller in Codeigniter. Is it possible by some trick or something?
Screenshot here: http://i.imgur.com/vrQ1J9V.png
If it will be like
/controllers/manage/manage.php
you should add in /config/routes.php
$route['manage/(.*)'] = "manage/manage/$1";
$route['manage'] = "manage/manage";
There is no problem in using the same name, but it is confusing. The best solution would be to change the name, but you can use just fine.
Remember to use the routes with 'manage/manage/function'.
EDIT
I incorrectly viewed the first time and thought manage.php was outside the manage folder.
It will work, but your URL will just have "manage" twice. You could change the routes config to remove the first "manage", but it will be less confusing and time-consuming to just name manage.php something different.

Sorting a view by dropdown

Hey, i've been looking around for a ajax dropdown sorter for my Views in Drupal.
Unfortunatly, i haven't found alot of usefull information about this subject.
Can anyone tell me if theres a solution already available or can help me started on a custom module by telling me which hooks i should use?
I had a similar issue. Unfortunately I wasn't able to sort the data from the database which is by far the best way. I was however able to take the data and sort it with PHP using a preprocessor function. Depending on the name of your view, setup a function similar to the following:
function templatename_preprocess_name_of__view(&$vars)
{
//Super sweet sorting code goes here
}
The name of your view needs to follow the name of the template file that it is driven by, if there isn't on you should create one. Make sure to change dashes to underscores in your function name. Hope this is helpful. If you find a way to do it from the DB I'm all ears because that would be super awesome.

Resources