Jump to content

Creating news module like CMS


Recommended Posts

Hello,

 

I'm trying to create a news module in Prestashop 1.5 that should have some similar functionalities like the build-in CMS functionalities, but I'm a bit stuck in the backoffice implementation.

 

I want it to be possible that a user can add/edit/delete a news item in the backoffice and it will be visible on the frontoffice, where it can be read. This last part works, but it only works because I have some dummy data in my database. I can't really figure out how to implement it in Prestashop 1.5 in my own custom module.

 

First step for me would be that I read all data from my table and show it in a list in my module, as in attached image.

 

I would like to have an 'add new' button (1), an edit/delete button (2) and a delete multiple button (3)

 

I guess that I need to use a HelperList for this, is this correct? I can't really find suitable documentation for this, or perhaps I'm searching on the wrong places.

 

Also, my module is extending the Module class, but I also saw examples of extending the AdminController class - which one should I use ?

 

Any help that points me into the right direction is highly appreciated :)

post-293571-0-66723300-1377002641_thumb.png

Link to comment
Share on other sites

I'm at beginning, but I made already one very small form that decides how many latest news messages should be shown on frontoffice:

 

$oHelper = new HelperForm();

    // Module, token and currentIndex
    $oHelper->module = $this;
    $oHelper->name_controller = $this->name;
    $oHelper->token = Tools::getAdminTokenLite('AdminModules');
    $oHelper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name;
    // Language
    $oHelper->default_form_language = $iLang;
    $oHelper->allow_employee_form_lang = $iLang;
    // Title and toolbar
    $oHelper->title = 'Settings';
    $oHelper->show_toolbar = true;	    // false -> remove toolbar
    $oHelper->toolbar_scroll = false;	  // yes - > Toolbar is always visible on the top of the screen.
    $oHelper->submit_action = 'submit'.$this->name;
    $oHelper->toolbar_btn = array(
	    'save' =>
	    array(
		    'desc' => $this->l('Save'),
		    'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name.
		    '&token='.Tools::getAdminTokenLite('AdminModules'),
	    ),
	    'back' => array(
		    'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'),
		    'desc' => $this->l('Back to list')
	    )
    );
    // Load current values
    $oHelper->fields_value['ANDARE_NEWS_MESSAGES'] = Configuration::get('ANDARE_NEWS_MESSAGES');
    $sReturn = $oHelper->generateForm($aFormFields);

 

so I want something similar that shows me all current news items & possibility to add a new news item

Link to comment
Share on other sites

×
×
  • Create New...