-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
98 lines (66 loc) · 2.96 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
cre8News plugin
==============
The 'cre8NewsPlugin' is a symfony plugin that provides easily
integration of news section on in any symfony project which is based on Propel ORM.
Installation
------------
* Make sure you have installed required plugins this one is using:
* sfDatePlugin (optional) - required if you going to use partial: newsByMonth
* Install the plugin using SVN:
https://www.cre8newmedia.com/svn/cre8/projects/plugins/symfony/cre8NewsPlugin/trunk
* Rebuild your model
$ symfony propel:build-model
$ symfony propel:build-sql
$ symfony propel:build-forms
$ symfony propel:build-filters
* Update your database tables by starting from scratch (it will delete all
the existing tables, then re-create them):
$ symfony propel:insert-sql
or you can just create the new tables by using the generated SQL
statements in `data/sql/plugins.cre8NewsPlugin.lib.model.schema.sql`
* Enable one or more modules in your `settings.yml` (optional)
* For your backend application: cre8NewsAdmin
* For your frontend application: cre8news
[php]
all:
.settings:
enabled_modules: [default, cre8news]
* Clear you cache
$ symfony cc
* For administration module type: http://my_admin_app/news
* For frontend application:
* Create new action to display list of news and use code like that:
[php]
c = Cre8NewsPeer::getActiveNewsCriteria();
if($request->hasParameter('date') && $request->getParameter('date') != 'all') {
if($timestamp = sfDateTimeToolkit::getTS($request->getParameter('date') . '-01')) {
try {
$sfDate = new sfDate($timestamp);
$c = Cre8NewsPeer::getBetweenDisplayDatesCriteria($sfDate->format_database(), $sfDate->finalDayOfMonth()->format_database(), $c);
} catch (Exception $e) {
}
}
}
$pager = new sfPropelPager('Cre8News', 20);
$pager->setCriteria($c);
$pager->setPage($this->getRequestParameter('page', 1));
$pager->init();
$this->pager = $pager;
* News By Month (optional) - requires sfDatePlugin to be installed
Basically add logic to your layout/template which gonna display (or not) content:
Example:
apps/frontend/templates/layout.php:
[php]
<?php include_partial('cre8news/newsByMonth'); ?>
[/php]
another example (using slot as logic):
[php]
<?php if(has_slot('newsByMonth')): ?>
<?php include_partial('cre8news/newsByMonth'); ?>
<?php endif; ?>
[/php]
To display it you need to set slot in your template like that:
apps/frontend/your_module/templates/your_template.php:
[php]
<?php slot('newsByMonth', true); ?>
[/php]