How AutoGenerate classes with cakePHP 2.7.x? - cakephp-bake

Seems like there is no documentation regarding it anywhere. any assist will be appreciated.

The documentation is available at http://book.cakephp.org/2.0/en/console-and-shells.html. Added this as an answer as per OP's suggestion.

If I'm not mistaken,what you mean is the Cake Console & Shell that can produce autogenerate code for Controller,Model & View for your application.
You can refer here for more info http://book.cakephp.org/2.0/en/console-and-shells.html.
You can use 'bake' shell to generate your mvc structure.
Example:
$cake bake all
will output all possible table on your database like below
---------------------------------------------------------------
Bake All
---------------------------------------------------------------
Possible Models based on your current database:
1.posts
2.users
Enter a number from the list above,
type in the name of another model, or 'q' to exit
and if you put 1,then the result will come out like below:
Baking `index` view file...
Creating file /Applications/XAMPP/htdocs/AQMCorporate/aqmtest/View/Posts/index.ctp
Wrote `/Applications/XAMPP/htdocs/AQMCorporate/aqmtest/View/Posts/index.ctp`
Baking `view` view file...
Creating file /Applications/XAMPP/htdocs/AQMCorporate/aqmtest/View/Posts/view.ctp
Wrote `/Applications/XAMPP/htdocs/AQMCorporate/aqmtest/View/Posts/view.ctp`
Baking `add` view file...
Creating file /Applications/XAMPP/htdocs/AQMCorporate/aqmtest/View/Posts/add.ctp
Wrote `/Applications/XAMPP/htdocs/AQMCorporate/aqmtest/View/Posts/add.ctp`
Baking `edit` view file...
Creating file /Applications/XAMPP/htdocs/AQMCorporate/aqmtest/View/Posts/edit.ctp
Wrote `/Applications/XAMPP/htdocs/AQMCorporate/aqmtest/View/Posts/edit.ctp`
Bake All complete
There you go with CakePHP console & shell.

Related

how can I enable Markdown in fossil tickets

Fossil docs says that markdown can be used in tickets as well. But I do not manage to turn it on.
https://www.fossil-scm.org/xfer/tktview/35343257ffd02ba47880 reports a similar problem.
I read a solution in the Fossil-scm mail list but I cannot find the exact email now. However I put my TH1 templates for ticket in the following snippet:
https://bitbucket.org/snippets/ivzhh/GeL9pq
The basic idea is to set $mutype to markdown (x-markdown or x-fossil-markdown). Then add the redering code on line 75~82 in ticket-edit.tcl (the original solution is this post). The markdown rendering returns two values instead of one (default fossil wiki command). Please check the snippet.
I managed to get it work and have created a fossil repository with the three templates I created a repository with the patches on https://chiselapp.com/user/bwl21/repository/fossil-markdown-patches. The repository holds the files but also has applied the same in the configuration such that you can see how it works.
Thanks to #etc-100g

templating system with zf2?

we are planing to create a CMS with zf2 and doctrine orm .
actually we are concern about our cms templating
we want our system works with several templates and easily change between themes via admin
and creating a new templates should be easy for end-users developers
we want an advice or suggest for how to build templating system that :
there is a core module and there a lot sub modules with their own phtml
so where to store theme1 phtml and where to store theme2 phtmls ...
any suggest or advice please
thanks
I encourage you to take a look at Twig, its the best template engine I have seen so far :) It does take some time to learn Twig syntax, but its well worthy if you look at what you get :)
I cant yet write comments, so I wrote this as an answare.
Hope this helps. Trust me, the Twig is the way to go. Joust look at his documentation for more specific details how to use it!
EDIT:
The problem you are trying to solve has nothing to do with template engine. You can do that with any template engine. You can do it even with plain PHP if you want.
I built web application where users can register, get their own sub domain, and there they can build their webpage. Change theme, edit text, add pages. Simple CMS functionality.
The easiest way to do this is to have themes folder, where you would store themes, like this:
themes/
- themeBlue
- css/
- images/
- js/
- html or views/
- themeRose
...
Now this is where you would place all your themes, every theme has its own folder with images, css, js files...
And then you would have users, and every user would be able to choose and change theme.
That information would be stored in database. You need to store that user Jack is using themeBlue. You can do that as you want. You can event put this in users table like user_theme column.
Now when someone visits site, you first query database to see what theme is that user or creator of web using. And then you load all that files from current theme folder. And populate html files with data stored in database like in any other CMS.
This is the simplest implementation. You could for example, store css and html files in database :)
Hope this answers your question.
Good luck with that, I almost gone mad building my system :) I ended up with writing my own PHP MVC Framework joust to accomplish what I wanted.
if you activate another module in the application.config.php which has the same views and layouts (same folder structure and filenames) it's viewscripts and layouts will automatically be used when it's loaded after your core module.
so you could simply make your application.config.php dynamic to load the active template module which only contains the view folder. this would be a simple and effective solution without any other libraries.
additionally you can use an asset manager like assetic to also provide images, css etc. inside of your (template-)modules. (have a look at zf2-assetic-module, I wrote my own assetize-module based on assetic to fit my needs...)
Sina,
I do this in my Application->Module.php onBootstrap
$ss = $serviceManager->get('application_settings_service');
$settings = $ss->loadSettings();
$serviceManager->get('translator');
$templatePathResolver = $serviceManager->get('Zend\View\Resolver\TemplatePathStack');
$templatePathResolver->setPaths(array(__DIR__ . '/view/'.$settings['theme'])); // here is your skin name
$viewModel = $application->getMvcEvent()->getViewModel();
$viewModel->themeurl = 'theme/'.$settings['theme'].'/';
In this situation I have this structure in my view folder
view/
default/
application/
error/
layout/
zfcuser/
red/
application/
error/
layout/
zfcuser/
The $viewmodel above injects a variable into the layout for the themeurl in the public_html folder /theme/red/ with all assets for red
Access in layout.phtml -> themeurl;?> in a viewscript layout()->themeurl;?>
I am still working out my Dynamic Views. Right now I have a BaseController and all my ActionControllers extend it. It has a render() function that builds the required views but not sure its going to be scalable hoping to try some placeholder ideas.
application_settings_service is a Settings Service that gets settings for whatever domain was used to call the system and builds an array accessible via any service aware part of the site. Thats a whole different post and it may or may not rub MVC peeps the wrong way
I know your question is marked answered just thought I would share
Eric

django-jqgrid: how to settup the given example

I want to try django-jqgrid but the steps given as an example in the README.md file are not clear enough. In particular step 4, which reads Configure jgrid to use the defined urls., is too vague.
In what file the javascript code snippet given in the instruction should be put? Is an HTML template needed? More detailed steps would help.
django-jqgrid-demo is a small demo application for django-jqgrid I am writing. The initial goal is to present data from a model in a tabular format, with sorting and filtering. So I defined the model class, the grid class, the viewer functions and the urls by following the steps in the django-jqgrid documentation (except for step 4). What is missing is a template for presenting the data. Any help on how to complete it is welcome.

Adding views/blocks programatically to tpl.php files in Drupal 7

I am trying to integrate the awkward showcase into my page--front.tpl.php. My first idea was to create a custom content type (slideshow image) and then a view that prints a list of those images. I was able to create the view and set it to be available as a block... but I have no idea how to include that block via my .tpl.php file. I don't want to just use the content region because it displays a bunch of "hello welcome to $sitename" messages that I couldn't figure out how to remove.
Also, what is the naming convention for views blocks? The machine name for the view I want to create a template of is called 'front_page_slideshow'
There's a way of adding views programatically,
the easiest way is using "views_embed_view()" http://api.drupal.org/api/views/views.module/function/views_embed_view/7
$view = views_embed_view('view_name', 'display', $args);
print $view;
For render a block (any kind of block) use this simple script I created:
https://gist.github.com/4001153
I would create a region['slideshow'] in your template. Then you assign the view that you've already created into it as a block. If you want to get really simple, till you figure how to drupal properly, you can just hack your page--front.tpl.php file and use include('yourslideshowfile.php'); to simply include your file there.

BitBucket Wiki: Create a hierarchy structure?

I want to create a hierarchy in my wiki like so:
General
FooPages
Foo1
Foo2
Foo3
ODP
Bar
Baz
I would like to create these pages, and use <<toc>> table of contents macros to organize them.
How can I do that? Do I need to clone and edit the wiki on my own machine, or can I do that exclusively through the web interface?
You can (partially) do this, using <<toc / >>.
This will create a TOC for all the headers in files in the root directory.
It will not list headers in file in the sub directories, though.
You can do the same for <<toc FooPages/ >> etc.
You can do this both through the web interface and locally on your machine.
I placed some TOC examples on this Bitbucket wiki page: http://bitbucket.org/marijnvanderzee/build-wiki/wiki/TocTests. You can view the markup there.
Make sure to balance the equal signs on you headers; e.g. use == H2 == instead of == H2.
Both are valid, but at this time, the latter is not recognized by the <<toc>> macro.
Regarding the hierarchy side of this question, it's worth clarifying:
You can create a hierarchical structure by using the Title field when you create or edit a wiki page.
Eg: If you want to create a new file Bar.md inside a new Foo directory, just create a new page and in the Title field write "Foo/Bar.md". It will create the directory and the file at the same time.
I'm not sure if there's a way to just create the directory without adding a file to it straight away.
Regarding the TOC half of this question, I found that I can use the # HeaderTitle syntax in Markdown pages, and Creole's TOC macro will recognise it.