dolibarr 21.0.0-alpha
getnews.php
1<?php
2
3// Just for display errors in editor
4ini_set('display_errors', 1);
5
6if (!defined('NOTOKENRENEWAL')) {
7 define('NOTOKENRENEWAL', '1'); // Disables token renewal
8}
9if (!defined('NOREQUIREMENU')) {
10 define('NOREQUIREMENU', '1');
11}
12if (!defined('NOREQUIREHTML')) {
13 define('NOREQUIREHTML', '1');
14}
15if (!defined('NOREQUIREAJAX')) {
16 define('NOREQUIREAJAX', '1');
17}
18if (!defined('NOREQUIRESOC')) {
19 define('NOREQUIRESOC', '1');
20}
21require_once '../../main.inc.php';
22require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
23
25
26if ($_SERVER['REQUEST_METHOD'] == 'POST' && GETPOSTISSET('selectedIds')) {
27 $selectedIds = json_decode(GETPOST('selectedIds'), true);
28
29 $websitepage = new WebsitePage($db);
30 $selectedPosts = array();
31
32 foreach ($selectedIds as $id) {
33 $blog = new WebsitePage($db);
34 $blog->fetch($id);
35
36 $selectedPosts[] = array(
37 'id' => $blog->id,
38 'title' => $blog->title,
39 'description' => $blog->description,
40 'date_creation' => $blog->date_creation,
41 'image' => $blog->image,
42 );
43 }
44
45 print json_encode($selectedPosts);
46} else {
47 print json_encode(array('error' => 'Invalid request'));
48}
$id
Definition account.php:39
Class Websitepage.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.