dDLMD3ISLu4sOUad - Version 0.0.2

Version Notes

This module provide complete FAQ management.

Download this release

Release Info

Developer Kashif Saleem
Extension dDLMD3ISLu4sOUad
Version 0.0.2
Comparing to
See all releases


Code changes from version 0.0.1 to 0.0.2

app/code/community/Folio3/Faq/Block/Adminhtml/Faq.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Folio3_Faq_Block_Adminhtml_Faq extends Mage_Adminhtml_Block_Widget_Grid_Container {
4
+
5
+ protected function _construct() {
6
+ parent::_construct();
7
+
8
+ /**
9
+ * The $_blockGroup property tells Magento which alias to use to
10
+ * locate the blocks to be displayed in this grid container.
11
+ * In our example, this corresponds to Folio3_Faq/Block/Adminhtml.
12
+ */
13
+ $this->_blockGroup = 'folio3_faq_adminhtml';
14
+
15
+ /**
16
+ * $_controller is a slightly confusing name for this property.
17
+ * This value, in fact, refers to the folder containing our
18
+ * Grid.php and Edit.php - in our example,
19
+ */
20
+ $this->_controller = 'faq';
21
+
22
+ /**
23
+ * The title of the page in the admin panel.
24
+ */
25
+ $this->_headerText = Mage::helper('folio3_faq')
26
+ ->__('Faq');
27
+ }
28
+
29
+ public function getCreateUrl() {
30
+ /**
31
+ * When the "Add" button is clicked, this is where the user should
32
+ * be redirected to - in our example, the method editAction of
33
+ * faqController.php in Folio3_Faq module.
34
+ */
35
+ return $this->getUrl(
36
+ 'folio3_faq_admin/faq/edit'
37
+ );
38
+ }
39
+
40
+ }
app/code/community/Folio3/Faq/Block/Adminhtml/Faq/Edit.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Folio3_Faq_Block_Adminhtml_Faq_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
4
+
5
+ protected function _construct() {
6
+ $this->_blockGroup = 'folio3_faq_adminhtml';
7
+ $this->_controller = 'faq';
8
+
9
+ /**
10
+ * The $_mode property tells Magento which folder to use
11
+ * to locate the related form blocks to be displayed in
12
+ * this form container. In our example, this corresponds
13
+ * to BrandDirectory/Block/Adminhtml/Brand/Edit/.
14
+ */
15
+ $this->_mode = 'edit';
16
+
17
+ $newOrEdit = $this->getRequest()->getParam('id') ? $this->__('Edit') : $this->__('New');
18
+ $this->_headerText = $newOrEdit . ' ' . $this->__('Faq');
19
+ }
20
+
21
+ }
app/code/community/Folio3/Faq/Block/Adminhtml/Faq/Edit/Form.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Folio3_Faq_Block_Adminhtml_Faq_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
4
+
5
+ protected function _prepareForm() {
6
+ // Instantiate a new form to display our folio3_faq for editing.
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl(
10
+ 'folio3_faq_admin/faq/edit', array(
11
+ '_current' => true,
12
+ 'continue' => 0,
13
+ )
14
+ ),
15
+ 'method' => 'post',
16
+ ));
17
+ $form->setUseContainer(true);
18
+ $this->setForm($form);
19
+
20
+ // Define a new fieldset. We need only one for our simple entity.
21
+ $fieldset = $form->addFieldset(
22
+ 'general', array(
23
+ 'legend' => $this->__('Faq')
24
+ )
25
+ );
26
+
27
+ $forumoptionsSingleton = Mage::getSingleton(
28
+ 'folio3_faq/faq'
29
+ );
30
+
31
+ // Add the fields that we want to be editable.
32
+ $this->_addFieldsToFieldset($fieldset, array(
33
+ 'faq_question' => array(
34
+ 'label' => $this->__('Question'),
35
+ 'input' => 'text',
36
+ 'required' => true,
37
+ ),
38
+ 'faq_answer' => array(
39
+ 'label' => $this->__('Answer'),
40
+ 'input' => 'textarea',
41
+ 'required' => true,
42
+ ),
43
+ ));
44
+ return $this;
45
+ }
46
+
47
+ /**
48
+ * This method makes life a little easier for us by pre-populating
49
+ * fields with $_POST data where applicable and wrapping our post data
50
+ * in 'FaqData' so that we can easily separate all relevant information
51
+ * in the controller. You could of course omit this method entirely
52
+ * and call the $fieldset->addField() method directly.
53
+ */
54
+ protected function _addFieldsToFieldset(
55
+ Varien_Data_Form_Element_Fieldset $fieldset, $fields) {
56
+ $requestData = new Varien_Object($this->getRequest()
57
+ ->getPost('faqData'));
58
+
59
+ foreach ($fields as $name => $_data) {
60
+ if ($requestValue = $requestData->getData($name)) {
61
+ $_data['value'] = $requestValue;
62
+ }
63
+
64
+ // Wrap all fields with faqData group.
65
+ $_data['name'] = "faqData[$name]";
66
+
67
+ // Generally, label and title are always the same.
68
+ $_data['title'] = $_data['label'];
69
+
70
+ // If no new value exists, use the existing Faq data.
71
+ if (!array_key_exists('value', $_data)) {
72
+ $_data['value'] = $this->_getFaq()->getData($name);
73
+ }
74
+
75
+ // Finally, call vanilla functionality to add field.
76
+ $fieldset->addField($name, $_data['input'], $_data);
77
+ }
78
+
79
+ return $this;
80
+ }
81
+
82
+ /**
83
+ * Retrieve the existing Faq for pre-populating the form fields.
84
+ * For a new Folio3_Faq entry, this will return an empty Folio3_Faq object.
85
+ */
86
+ protected function _getFaq() {
87
+ if (!$this->hasData('faq')) {
88
+ // This will have been set in the controller.
89
+ $faq = Mage::registry('current_faq');
90
+
91
+ // Just in case the controller does not register the Folio3_Faq.
92
+ if (!$faq instanceof
93
+ Folio3_Faq_Model_Faq) {
94
+ $faq = Mage::getModel(
95
+ 'folio3_faq/faq'
96
+ );
97
+ }
98
+
99
+ $this->setData('faq', $faq);
100
+ }
101
+
102
+ return $this->getData('faq');
103
+ }
104
+
105
+ }
app/code/community/Folio3/Faq/Block/Adminhtml/Faq/Grid.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Folio3_Faq_Block_Adminhtml_Faq_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ protected function _prepareCollection() {
6
+ /**
7
+ * Tell Magento which collection to use to display in the grid.
8
+ */
9
+ $collection = Mage::getResourceModel(
10
+ 'folio3_faq/faq_collection'
11
+ );
12
+ $this->setCollection($collection);
13
+ return parent::_prepareCollection();
14
+ }
15
+
16
+ public function getRowUrl($row) {
17
+ /**
18
+ * When a grid row is clicked, this is where the user should
19
+ * be redirected to - in our example, the method editAction of
20
+ * FaqController.php in Folio3_Faq module.
21
+ */
22
+ return $this->getUrl(
23
+ 'folio3_faq_admin/faq/edit', array(
24
+ 'id' => $row->getId()
25
+ )
26
+ );
27
+ }
28
+
29
+ protected function _prepareColumns() {
30
+ /**
31
+ * Here, we'll define which columns to display in the grid.
32
+ */
33
+ $this->addColumn('id', array(
34
+ 'header' => $this->_getHelper()->__('ID'),
35
+ 'type' => 'number',
36
+ 'index' => 'id',
37
+ ));
38
+
39
+ $this->addColumn('faq_question', array(
40
+ 'header' => $this->_getHelper()->__('Questions'),
41
+ 'type' => 'text',
42
+ 'index' => 'faq_question',
43
+ ));
44
+
45
+ $this->addColumn('faq_answer', array(
46
+ 'header' => $this->_getHelper()->__('Answers'),
47
+ 'type' => 'text',
48
+ 'index' => 'faq_answer',
49
+ ));
50
+
51
+ $forumoptionsSingleton = Mage::getSingleton(
52
+ 'folio3_faq/faq'
53
+ );
54
+
55
+ /**
56
+ * Finally, we'll add an action column with an edit link.
57
+ */
58
+ $this->addColumn('action', array(
59
+ 'header' => $this->_getHelper()->__('Action'),
60
+ 'width' => '50px',
61
+ 'type' => 'action',
62
+ 'actions' => array(
63
+ array(
64
+ 'caption' => $this->_getHelper()->__('Edit'),
65
+ 'url' => array(
66
+ 'base' => 'folio3_faq_admin'
67
+ . '/faq/edit',
68
+ ),
69
+ 'field' => 'id'
70
+ ),
71
+ ),
72
+ 'filter' => false,
73
+ 'sortable' => false,
74
+ 'index' => 'id',
75
+ ));
76
+
77
+ return parent::_prepareColumns();
78
+ }
79
+
80
+ protected function _getHelper() {
81
+ return Mage::helper('folio3_faq');
82
+ }
83
+
84
+ }
app/code/community/Folio3/Faq/Helper/Data.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Folio3_Faq_Helper_Data extends Mage_Core_Helper_Abstract {
4
+
5
+ }
6
+
7
+ ?>
app/code/community/Folio3/Faq/Model/Faq.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Folio3_Faq_Model_Faq extends Mage_Core_Model_Abstract {
4
+
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('folio3_faq/faq');
9
+ }
10
+
11
+ /**
12
+ * This method is used in the grid and form for populating the dropdown.
13
+ */
14
+ public function getAvailableVisibilies()
15
+ {
16
+ return array(
17
+ self::VISIBILITY_HIDDEN
18
+ => Mage::helper('folio3_faq')
19
+ ->__('Hidden'),
20
+ self::VISIBILITY_DIRECTORY
21
+ => Mage::helper('folio3_faq')
22
+ ->__('Visible in Directory'),
23
+ );
24
+ }
25
+ protected function _beforeSave()
26
+ {
27
+ parent::_beforeSave();
28
+ /**
29
+ * Perform some actions just before a faq is saved.
30
+ */
31
+ $this->_updateTimestamps();
32
+ $this->_prepareUrlKey();
33
+ return $this;
34
+ }
35
+ protected function _updateTimestamps()
36
+ {
37
+ $timestamp = now();
38
+ /**
39
+ * Set the last updated timestamp.
40
+ */
41
+ $this->setUpdatedAt($timestamp);
42
+ /**
43
+ * If we have a faq new object, set the created timestamp.
44
+ */
45
+ if ($this->isObjectNew()) {
46
+ $this->setCreatedAt($timestamp);
47
+ }
48
+ return $this;
49
+ }
50
+ protected function _prepareUrlKey()
51
+ {
52
+ /**
53
+ * In this method, you might consider ensuring
54
+ * that the URL Key entered is unique and
55
+ * contains only alphanumeric characters.
56
+ */
57
+ return $this;
58
+ }
59
+
60
+ }
app/code/community/Folio3/Faq/Model/Resource/Faq.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Folio3_Faq_Model_Resource_Faq extends Mage_Core_Model_Resource_Db_Abstract {
4
+
5
+ protected function _construct() {
6
+ /**
7
+ * Tell Magento the database name and primary key field to persist
8
+ * data to. Similar to the _construct() of our model, Magento finds
9
+ * this data from config.xml by finding the <resourceModel/> node
10
+ * and locating children of <entities/>.
11
+ *
12
+ * In this example:
13
+ * - Folio3_Faq is the model alias
14
+ * - faq is the entity referenced in config.xml
15
+ * - id is the name of the primary key column
16
+ *
17
+ * As a result, Magento will write data to the table
18
+ * 'folio3_faq/faq' and any calls
19
+ * to $model->getId() will retrieve the data from the
20
+ * column named 'id'.
21
+ */
22
+ $this->_init('folio3_faq/faq', 'id');
23
+ }
24
+
25
+ }
app/code/community/Folio3/Faq/Model/Resource/Faq/Collection.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Folio3_Faq_Model_Resource_Faq_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
4
+
5
+ protected function _construct() {
6
+ parent::_construct();
7
+
8
+ /**
9
+ * Tell Magento the model and resource model to use for
10
+ * this collection. Because both aliases are the same,
11
+ * we can omit the second paramater if we wish.
12
+ */
13
+ $this->_init(
14
+ 'folio3_faq/faq', 'folio3_faq/faq'
15
+ );
16
+
17
+ }
18
+
19
+ }
app/code/community/Folio3/Faq/Model/Resource/Setup.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Folio3_Faq_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup {
4
+
5
+ }
6
+
7
+ ?>
app/code/community/Folio3/Faq/Model/Source/Faq.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Folio3_Faq_Model_Source_Faq extends Mage_Eav_Model_Entity_Attribute_Source_Abstract {
4
+
5
+
6
+
7
+ }
app/code/community/Folio3/Faq/controllers/Adminhtml/FaqController.php ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Folio3_Faq_Adminhtml_FaqController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ /**
6
+ * Instantiate our grid container block and add to the page content.
7
+ * When accessing this admin index page, we will see a grid of all
8
+ * Faq currently available in our Magento instance, along with
9
+ * a button to add a new one if we wish.
10
+ */
11
+ public function indexAction() {
12
+ // instantiate the grid container
13
+ $faqBlock = $this->getLayout()
14
+ ->createBlock('folio3_faq_adminhtml/faq');
15
+ $this->loadLayout();
16
+ $this->_setActiveMenu('folio3_faq');
17
+ $this->_addContent($faqBlock);
18
+ $this->renderLayout();
19
+ }
20
+
21
+ public function gridAction()
22
+ {
23
+ $this->loadLayout();
24
+ $this->getResponse()->setBody(
25
+ $this->getLayout()->createBlock('folio3_faq/adminhtml_faq_grid')->toHtml()
26
+ );
27
+ }
28
+
29
+ /**
30
+ * This action handles both viewing and editing existing faq.
31
+ */
32
+ public function editAction()
33
+ {
34
+ /**
35
+ * Retrieve existing forum data if an ID was specified.
36
+ * If not, we will have an empty forum entity ready to be populated.
37
+ */
38
+
39
+ $faq = Mage::getModel('folio3_faq/faq');
40
+ if ($faqId = $this->getRequest()->getParam('id', false)) {
41
+ $faq->load($faqId);
42
+ if (!$faq->getId()){
43
+ $this->_getSession()->addError(
44
+ $this->__('This faq no longer exists.')
45
+ );
46
+ return $this->_redirect('folio3_faq_admin/faq/index');
47
+ }
48
+ }
49
+ //}
50
+
51
+ // process $_POST data if the form was submitted
52
+ if ($postData = $this->getRequest()->getPost('faqData')) {
53
+
54
+ try {
55
+ $faq->addData($postData);
56
+ $faq->save();
57
+
58
+ $this->_getSession()->addSuccess(
59
+ $this->__('The faq has been saved.')
60
+ );
61
+
62
+ // redirect to remove $_POST data from the request
63
+ return $this->_redirect(
64
+ 'folio3_faq_admin/faq/edit',
65
+ array('id' => $faq->getId())
66
+ );
67
+ }
68
+ catch (Exception $e) {
69
+ Mage::logException($e);
70
+ $this->_getSession()->addError($e->getMessage());
71
+ }
72
+
73
+ /**
74
+ * If we get to here, then something went wrong. Continue to
75
+ * render the page as before, the difference this time being
76
+ * that the submitted $_POST data is available.
77
+ */
78
+ }
79
+
80
+ // Make the current forum object available to blocks.
81
+ Mage::register('current_faq', $faq);
82
+
83
+ // Instantiate the form container.
84
+ $faqEditBlock = $this->getLayout()->createBlock(
85
+ 'folio3_faq_adminhtml/faq_edit'
86
+ );
87
+
88
+ // Add the form container as the only item on this page.
89
+ $this->loadLayout()
90
+ ->_setActiveMenu('folio3_faq/faq')
91
+ ->_addContent($faqEditBlock)
92
+ ->renderLayout();
93
+ }
94
+
95
+
96
+ public function deleteAction() {
97
+ $params = $this->getRequest()->getParams();
98
+ $faq = Mage::getModel('folio3_faq/faq');
99
+ $faq->load($params['id']);
100
+ $faq->delete();
101
+ Mage::getSingleton('core/session')->addSuccess(Mage::helper('folio3_faq')->__('Question Successfully Deleted'));
102
+ return $this->_redirect('folio3_faq_admin/faq/index');
103
+ }
104
+
105
+
106
+
107
+ public function postAction() {
108
+ if ($data = $this->getRequest()->getPost()) {
109
+
110
+ //create Folio3_Faq model object
111
+ $model = Mage::getModel('folio3_faq/faq');
112
+
113
+ $model->setData($data);
114
+ var_dump ($data);
115
+ die();
116
+ try {
117
+
118
+ //Save form data in Folio3_Faq_Info table
119
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
120
+ $model->setCreatedTime(now())
121
+ ->setUpdateTime(now());
122
+ } else {
123
+ $model->setUpdateTime(now());
124
+ }
125
+
126
+
127
+ $model
128
+ ->setFaqQuestion($data['faq']['faq_question'])
129
+ ->setFaqAnswer($data['faq']['faq_answer'])
130
+ ->save();
131
+
132
+ //To unset model object -- do not comment out this
133
+ $model->unsetData();
134
+
135
+
136
+ Mage::getSingleton('core/session')->addSuccess(Mage::helper('folio3_faq')->__('Item was successfully saved'));
137
+ Mage::getSingleton('core/session')->setFormData(false);
138
+
139
+ if ($this->getRequest()->getParam('back')) {
140
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
141
+ return;
142
+ }
143
+ $this->_redirect('*/*/');
144
+ return;
145
+ } catch (Exception $e) {
146
+ Mage::getSingleton('core/session')->addError($e->getMessage());
147
+ Mage::getSingleton('core/session')->setFormData($data);
148
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
149
+ return;
150
+ }
151
+ }
152
+ Mage::getSingleton('core/session')->addError(Mage::helper('folio3_faq')->__('Unable to find item to save'));
153
+ $this->_redirect('*/*/');
154
+ }
155
+
156
+ }
app/code/community/Folio3/Faq/controllers/IndexController.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Folio3_Faq_IndexController extends Mage_Core_Controller_Front_Action {
4
+
5
+ public function indexAction() {
6
+ $this->loadLayout();
7
+ $block = $this->getLayout()->createBlock(
8
+ 'Mage_Core_Block_Template', 'folio3_faq.faq', array(
9
+ 'template' => 'folio3_faq/faq.phtml'
10
+ )
11
+ );
12
+ $this->getLayout()->getBlock('content')->append($block);
13
+ $this->_initLayoutMessages('core/session');
14
+ $this->renderLayout();
15
+ }
16
+
17
+ public function viewAction() {
18
+ $this->loadLayout();
19
+ $this->renderLayout();
20
+ }
21
+ }
app/code/community/Folio3/Faq/etc/adminhtml.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <folio3_faq translate="title" module="folio3_faq">
5
+ <title>Manage FAQ</title>
6
+ <sort_order>76</sort_order>
7
+ <action>folio3_faq_admin/faq</action>
8
+ </folio3_faq>
9
+ </menu>
10
+ </config>
app/code/community/Folio3/Faq/etc/config.xml ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Folio3_Faq>
5
+ <!--
6
+ This is the version number that our module is currently at.
7
+ In order for setup scripts to run, their version number must
8
+ be less than or equal to this value.
9
+
10
+ As we add upgrade scripts, we increment this value. The next time
11
+ your Magento instance is accessed, Magento will compare values in
12
+ the database table 'core_resource' against this value. If the
13
+ database is lower, it will attempt to run any setup scripts for
14
+ the module and then update the database table to match this value.
15
+ -->
16
+ <version>0.0.1</version>
17
+ </Folio3_Faq>
18
+ </modules>
19
+ <resources>
20
+ <folio3_faq_read>
21
+ <connection>
22
+ <use>core_read</use>
23
+ </connection>
24
+ </folio3_faq_read>
25
+ <folio3_faq_write>
26
+ <connection>
27
+ <use>core_write</use>
28
+ </connection>
29
+ </folio3_faq_write>
30
+ <folio3_faq_setup>
31
+ <setup>
32
+ <module>Folio3_Faq</module>
33
+ <class>Folio3_Faq_Model_Resource_Setup</class>
34
+ </setup>
35
+ <connection>
36
+ <use>core_setup</use>
37
+ </connection>
38
+ </folio3_faq_setup>
39
+ </resources>
40
+
41
+ <global>
42
+
43
+
44
+ <blocks>
45
+ <!--
46
+ add an adminhtml block definition
47
+ -->
48
+ <folio3_faq_adminhtml>
49
+ <class>Folio3_Faq_Block_Adminhtml</class>
50
+ </folio3_faq_adminhtml>
51
+ <!--
52
+ add an frontend block definition
53
+ -->
54
+ <folio3_faq>
55
+ <class>Folio3_Faq_Block</class>
56
+ </folio3_faq>
57
+
58
+ </blocks>
59
+ <!--
60
+ Add a helper definition for use in adminhtml.xml menu translation.
61
+ -->
62
+ <helpers>
63
+ <folio3_faq>
64
+ <class>Folio3_Faq_Helper</class>
65
+ </folio3_faq>
66
+ </helpers>
67
+ <models>
68
+ <!--
69
+ This is the model alias referred to in install-0.0.1.php.
70
+ -->
71
+ <folio3_faq>
72
+ <!--
73
+ This tells Magento where to find models for this module.
74
+ -->
75
+ <class>Folio3_Faq_Model</class>
76
+ <!--
77
+ This tells Magento where to find resource
78
+ materials for this module.
79
+ -->
80
+ <resourceModel>folio3_faq_resource</resourceModel>
81
+ </folio3_faq>
82
+
83
+ <!--
84
+ This alias must match the <resourceModel/> value above.
85
+ -->
86
+ <folio3_faq_resource>
87
+ <!--
88
+ This tells Magento where to find resource
89
+ models for this module.
90
+ -->
91
+ <class>Folio3_Faq_Model_Resource</class>
92
+ <entities>
93
+ <!--
94
+ This is the table alias referred to in install-0.0.1.php.
95
+ -->
96
+ <faq>
97
+ <!--
98
+ This is the name of the database table itself.
99
+ -->
100
+ <table>folio3_faq</table>
101
+ </faq>
102
+ </entities>
103
+ </folio3_faq_resource>
104
+ </models>
105
+
106
+ <resources>
107
+ <!--
108
+ This must match our folder name in the module sql folder.
109
+ -->
110
+ <folio3_faq_setup>
111
+ <setup>
112
+ <!--
113
+ This defines which module the setup
114
+ scripts in this location belong to.
115
+ -->
116
+ <module>Folio3_Faq</module>
117
+ <!--
118
+ In each setup script, this
119
+ value determines the class of $this.
120
+ -->
121
+ <class>Mage_Core_Model_Resource_Setup</class>
122
+ </setup>
123
+ <!--
124
+ This is relevant only if you have multiple database connections.
125
+ -->
126
+ <connection>
127
+ <use>core_setup</use>
128
+ </connection>
129
+ </folio3_faq_setup>
130
+ </resources>
131
+
132
+
133
+ </global>
134
+ <!-- Add a router for access to our admin panel controller. -->
135
+ <admin>
136
+ <routers>
137
+ <!-- This is the alias for this router. -->
138
+ <folio3_faq_admin>
139
+ <!--
140
+ This basically informs Magento to use the
141
+ admin scope for requests to this router.
142
+ -->
143
+ <use>admin</use>
144
+ <args>
145
+ <!--
146
+ This tells Magento where to find
147
+ adminhtml controllers for this module.
148
+ -->
149
+ <module>Folio3_Faq_Adminhtml</module>
150
+ <!-- This is the term used in the actual URL. -->
151
+ <frontName>faq</frontName>
152
+ </args>
153
+ </folio3_faq_admin>
154
+ </routers>
155
+ </admin>
156
+
157
+ <frontend>
158
+ <layout>
159
+ <updates>
160
+ <folio3_faq>
161
+ <file>Folio3_Faq.xml</file>
162
+ </folio3_faq>
163
+ </updates>
164
+ </layout>
165
+ <routers>
166
+ <folio3_faq>
167
+ <use>standard</use>
168
+ <args>
169
+ <module>Folio3_Faq</module>
170
+ <frontName>faq</frontName>
171
+ </args>
172
+ </folio3_faq>
173
+ </routers>
174
+ <routers>
175
+ <customer>
176
+ <args>
177
+ <modules>
178
+ <folio3_faq before="Mage_Customer">Folio3_Faq</folio3_faq>
179
+ </modules>
180
+ </args>
181
+ </customer>
182
+ </routers>
183
+ </frontend>
184
+ <adminhtml>
185
+ <layout>
186
+ <updates>
187
+ <folio3_faq>
188
+ <file>folio3_faq.xml</file>
189
+ </folio3_faq>
190
+ </updates>
191
+ </layout>
192
+ </adminhtml>
193
+ </config>
app/code/community/Folio3/Faq/sql/folio3_faq_setup/install-0.0.1.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ */
5
+ $installer = $this;
6
+
7
+ $installer->startSetup();
8
+
9
+
10
+ $installer->run("CREATE TABLE IF NOT EXISTS `" . $this->getTable("folio3_faq") . "` (
11
+ `id` int unsigned NOT NULL auto_increment,
12
+ `faq_question` text NOT NULL,
13
+ `faq_answer` text NOT NULL,
14
+ PRIMARY KEY (`id`)
15
+ ) ENGINE=INNODB charset=utf8 COLLATE=utf8_unicode_ci COMMENT='this table is for faq'");
16
+
17
+ $installer->endSetup();
app/design/frontend/rwd/default/layout/folio3_faq.xml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.0.1">
3
+ <default>
4
+ </default>
5
+ <folio3_faq_index_index>
6
+ <reference name="root">
7
+ <!--<action method="setTemplate">
8
+ <template>page/empty.phtml</template>
9
+ </action>-->
10
+ </reference>
11
+ <reference name="content">
12
+ <block type="folio3_faq/faq" template="folio3_faq/faq.phtml" />
13
+ </reference>
14
+
15
+
16
+ </folio3_faq_index_index>
17
+
18
+ <folio3_faq_index_view>
19
+ <!--<reference name="content">
20
+ <block template="apex_watchnow/view.phtml" />
21
+ </reference>-->
22
+ </folio3_faq_index_view>
23
+
24
+ <!--<cms_index_index>
25
+ <reference name="content">
26
+ <block type="folio3_faq/faq" template="folio3_faq/faq.phtml">
27
+ <action method="setBlockId"><block_id>faq</block_id>
28
+ </action>
29
+ </block>
30
+ </reference>
31
+ </cms_index_index>-->
32
+ </layout>
app/design/frontend/rwd/default/template/folio3_faq/faq.phtml ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="content-header">
2
+ <table cellspacing="0" class="grid-header">
3
+ <tr>
4
+ <td><h3><?php print $this->__('FAQ')?></h3></td>
5
+ </tr>
6
+ </table>
7
+ </div>
8
+ <script type="text/javascript">
9
+ $(function(){
10
+ $('#accordion').accordion();
11
+ })
12
+ function showAnswer(divID)
13
+ {
14
+
15
+ //var ansNo = 'li-'+divID;
16
+ var x = document.getElementsByClassName('li-'+divID);
17
+ //alert(x);
18
+ var i;
19
+ for (i = 0; i < x.length; i++) {
20
+ if (x[i].style.display == 'none')
21
+ {
22
+ x[i].style.display = 'block';
23
+ }
24
+ else
25
+ {
26
+ x[i].style.display = 'none';
27
+ }
28
+ }
29
+ }
30
+ </script>
31
+ <div class="entry-edit">
32
+ <div class="fieldset">
33
+ <!--<table class="data border tabledata" id="list_table">
34
+
35
+ <tbody id="2_container" class="innertabledata" style="background-color: #ffffff;">-->
36
+
37
+ <?php
38
+ /*$collection = Mage::getModel('folio3_faq/faq')->getCollection();
39
+ $faq_detail = $collection->getData();
40
+
41
+ foreach($faq_detail as $row)
42
+ {
43
+ echo ("<tr>");
44
+ echo ("<td style='line-height:30px'><b>".$row['faq_question']."</b></td>");
45
+ echo ("</tr>");
46
+
47
+ echo ("<tr>");
48
+ echo ("<td style='line-height:30px'>".$row['faq_answer']."</td>");
49
+ echo ("</tr>");
50
+
51
+ echo ("<tr>");
52
+ echo ("<td style='line-height:25px'>&nbsp;</td>");
53
+ echo ("</tr>");
54
+ }*/
55
+ ?>
56
+ <!--</tbody>
57
+ <tfoot>
58
+
59
+ </tfoot>
60
+ </table>-->
61
+
62
+ <?php
63
+ $collection = Mage::getModel('folio3_faq/faq')->getCollection();
64
+ $faq_detail = $collection->getData();
65
+
66
+ foreach($faq_detail as $row)
67
+ {
68
+ echo ("<ul onclick='showAnswer(".$row['id'].")' style='line-height:30px;cursor:pointer'><b>".$row['faq_question']."</b>");
69
+ echo ("<li class='li-".$row['id']."' style='display:none'>".$row['faq_answer']."</li>");
70
+ echo ("</ul>");
71
+ }
72
+ ?>
73
+
74
+ </div>
75
+ </div>
app/etc/modules/Folio3_Faq.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Folio3_Faq>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Folio3_Faq>
8
+ </modules>
9
+ </config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>dDLMD3ISLu4sOUad</name>
4
- <version>0.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
@@ -12,9 +12,9 @@
12
  It is compatible with all Magento versions from 1.5.1.0, 1.6.0.0, 1.7.0.0, 1.8.0.0 or latest 1.9.0.1. </description>
13
  <notes>This module provide complete FAQ management.</notes>
14
  <authors><author><name>Kashif Saleem</name><user>ksaleem</user><email>ksaleem@folio3.com</email></author></authors>
15
- <date>2015-07-10</date>
16
- <time>11:41:41</time>
17
- <contents><target name="mageetc"><dir><dir name="app"><dir name="etc"><file name="module" hash=""/></dir></dir></dir></target><target name="magedesign"><dir><dir name="app"><dir name="design"><dir name="frontend"><dir name="rwd"><dir name="default"><file name="layout" hash=""/></dir></dir></dir></dir></dir></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.5.0</min><max>6.0.0</max></php></required></dependencies>
20
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>dDLMD3ISLu4sOUad</name>
4
+ <version>0.0.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
12
  It is compatible with all Magento versions from 1.5.1.0, 1.6.0.0, 1.7.0.0, 1.8.0.0 or latest 1.9.0.1. </description>
13
  <notes>This module provide complete FAQ management.</notes>
14
  <authors><author><name>Kashif Saleem</name><user>ksaleem</user><email>ksaleem@folio3.com</email></author></authors>
15
+ <date>2015-08-27</date>
16
+ <time>13:10:27</time>
17
+ <contents><target name="magecommunity"><dir name="Folio3"><dir name="Faq"><dir name="Block"><dir name="Adminhtml"><dir name="Faq"><dir name="Edit"><file name="Form.php" hash="27aee2b390a3676490fe636eada77bff"/></dir><file name="Edit.php" hash="6cfa25d2769b3b4c6574c636b2302fff"/><file name="Grid.php" hash="5e17c6ceffa094f2f591ea3046c6feb3"/></dir><file name="Faq.php" hash="b2c2d7b54541b1d43deb87f859a628b4"/></dir></dir><dir name="Helper"><file name="Data.php" hash="0d4eceee636d99392f77554008ce5d22"/></dir><dir name="Model"><file name="Faq.php" hash="c635ef1e10540c24f279a6e76f63bc1e"/><dir name="Resource"><dir name="Faq"><file name="Collection.php" hash="8f12c91465f48e665c9907ec8f14c97d"/></dir><file name="Faq.php" hash="ef349d46367e4713cdfdf73a713907fb"/><file name="Setup.php" hash="9fc3d16aafa09733ebd245e53aad2486"/></dir><dir name="Source"><file name="Faq.php" hash="55280b7482c306df3d886b940d2f7e14"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="FaqController.php" hash="54f1fc337a44560e9cf3996554199b3a"/></dir><file name="IndexController.php" hash="179f130738909681776ad357536e2409"/></dir><dir name="etc"><file name="adminhtml.xml" hash="c5c65ef854021b7d9dee507a61bcfc7b"/><file name="config.xml" hash="1389c6743a206e3c82c9ff6b082325d3"/></dir><dir name="sql"><dir name="folio3_faq_setup"><file name="install-0.0.1.php" hash="caa7083b48bc34e81d6061fda551ec87"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Folio3_Faq.xml" hash="a766a7f61f4a851f44c678dc7e1aa107"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="rwd"><dir name="default"><dir name="template"><dir name="folio3_faq"><file name="faq.phtml" hash="53d06233da4daea12ff3587dd901e05a"/></dir></dir><dir name="layout"><file name="folio3_faq.xml" hash="a689b7866191145cf516b9b87a1a3c3e"/></dir></dir></dir></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.5.0</min><max>6.0.0</max></php></required></dependencies>
20
  </package>