Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Remove auto center alignment

I have noticed that since running the 2.0 version, Phalcon seems to automatically place centering code into my views:

<div align="center">

Here are a few shots of the html element appearing. It seems to be added when the {{ content() }} function is used in .volt templates:

elements centered aligned

elements in code

showing it aooears from content function

evidence in code

Can someone tell me how to stop this from being placed in my templates?

Figured it out:

Turns out if you create a Controller (or scaffold using dev-tools which I did) titled users, then all templates in the users view directory will have <div align="center"> ... </div> wrapped around the loaded template through the {{ content() }} function. Renaming the controller and the views directory to anything else will remove the align="center" element.

I have no idea how to debug Phalcon so I unfortunately cannot supply a patch fix for this.

when using devtools, phalcon make a layout directory with your file name in your views directory. Edit the file or remove the layouts directory if you don't use it

when using devtools, phalcon make a layout directory with your file name in your views directory. Edit the file or remove the layouts directory if you don't use it

Yeah the issue appears to be any controller and view directory with the name user will have it's views wrapped in the center div element. I renamed my controller and view directory to admin and now it's gone. Therefore, I think there's some code in Phalcon's content render function that's causing the wrapping.



12.8k
Accepted
answer
edited May '15

when you create for example a scaffold for, lets say, 'access-list', phalcon will create:

-controller
 --AccessListController.php
-model
 --AccessList.php
-view
 --access_list
   ---access_list.volt
 --layouts
   ---access_list.volt

If you take a look in that layout you'll see

<div align="center">
    {{ content() }}
</div>

remove the div and that's all. Problem solved. Also you can remove the layouts directory entirely if you don't need it

when you create for example a scaffold for, lets say, 'access-list', phalcon will create:

-controller --AccessListController.php -model --AccessList.php -view --access_list ---access_list.volt --layouts ---access_list.volt

If you take a look in that layout you'll see

<div align="center"> {{ content() }} </div>

remove the div and that's all. Problem solved. Also you can remove the layouts directory entirely if you don't need it

Brilliant! Thanks for pointing that out :)