Is there any way to make the template get updated when the model is updated? - freemarker

I am using FreeMarker to generate an HTML.
However, I would like the template to get updated if I update the model.
Is it possible to achieve this kind of request ?
It just doesn't make sense to call to template.process(..) every time the model changes.
Thanks !

Well I guess it's not possible to have the html changed whenever the model is updated. Thanks ! :)

Related

How to differentiate between two dynamic url in Laravel

I have two dynamic url with simillar structure. For example, lets say, Product page and category page.
I have set both pages in
Route::get('/{product}', [UsersController:: class, 'productDetail']);
Route::get('/{category}', [UsersController:: class, 'categoryProducts']);
But when I click on url which suppose to go in category page, it redirect to product page only because of same structure. How I can differentiate both URLs for Laravel without altering their url structure?
I don't think this can be done without modifying the URL pattern at least a little bit.
If you do something like /50?type=category then in the show method you can use the query parameter to determine which table to look at. But you'll have to use the same show method and I don't recommend doing it this way.
I hope someone else will be able to shine some more light on the matter.
this is the best practice for your case to make yourapi Resful
Route::get('/product/{product-id}', [UsersController:: class, 'productDetail']);
Route::get('/product/categories, [UsersController:: class, 'categoryProducts']);
learn more about Restful api here https://restfulapi.net/resource-naming/
This should be done by calling index, update diff() function. You can try by using the below:
Route::get('/category/{slug}', 'site\categorycontroller#show')->name('category.show');
Route::get('/product/{slug}', 'site\productcontroller#show')->name('product.show');

Cakephp -how to use and where to put debug($var) in $this?

I want to know the value of the associative array $this in cakephp, base on my research I could use debug($this);
however I don't know where to put it, model, view or controller, and I don't know where to see the result of debug($this);.
I'm trying to get the value of $this so that I can use them in making a rest api using json_encode.
To elaborate the process
Content or what is inside of $this(part which I want to see)
json_encode
ajax
any help suggestions or opinions is highly appreciated

Laravel trouble routing to update Controller

I'm trying to edit a Alumne model with a model Form but I only have a NotFoundHttpException
The application only fails when I confirm the edit form. I think the problem is in the Form::model line but don't know.
Here's the entire code:
http://laravel.io/bin/62eq
Thanks.
All looks correct...
Check if $alumne really has id or is named different like alumne_id or id_alumne... Is the only thing may be.

Get list of Assert Constraints in FormType Extension in Symfony2.1

I'm trying to implement client side form validation with javascript and I'd like to use the Validation defined in the Entity or the Form by putting them in the fields data- property.
The problem is that I don't know nor find any information about how to get the constraints from within the FormType extension.
I thought that the FormBuilder should have access to the data as it is used to start validation, but there doesn't seem to be any method to retrieve constraints.
Thanks for any help
You can use:
$validators = $form->getConfig()->getValidators();
on your form object
Finally I found a solution. It may not be the best, but serves for me.
I injected the Validator service into the FormTypeExtension.
Then I could do
$this->validator->getMetadataFactory()->getClassMetadata($options['data_class']);
I also had to change the service alias from "field" to "form" to get the data_class in options.
Hope this helps someone having the same problem.
If needed I can publish more details.

Using CodeIgniter, how do I pass multiple variables via a GET form?

I figured out how to pass one.. but how do I pass multiple GET variables from a FORM?
This is the most repeated question of all time in CodeIgniter, second only to "How do I remove index.php".
How can I use GET forms with CodeIgniter?
Google is your friend.
sending data from get is really a hassle so i suggest u to use post data instead. its easy and safe.

Resources