dolibarr 21.0.0-beta
getnews.php
1<?php
2/* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
3 */
4
5// Just for display errors in editor
6ini_set('display_errors', 1);
7
8if (!defined('NOTOKENRENEWAL')) {
9 define('NOTOKENRENEWAL', '1'); // Disables token renewal
10}
11if (!defined('NOREQUIREMENU')) {
12 define('NOREQUIREMENU', '1');
13}
14if (!defined('NOREQUIREHTML')) {
15 define('NOREQUIREHTML', '1');
16}
17if (!defined('NOREQUIREAJAX')) {
18 define('NOREQUIREAJAX', '1');
19}
20if (!defined('NOREQUIRESOC')) {
21 define('NOREQUIRESOC', '1');
22}
23require_once '../../main.inc.php';
24require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
25
35
36if ($_SERVER['REQUEST_METHOD'] == 'POST' && GETPOSTISSET('selectedIds')) {
37 $selectedIds = json_decode(GETPOST('selectedIds'), true);
38
39 $websitepage = new WebsitePage($db);
40 $selectedPosts = array();
41
42 foreach ($selectedIds as $id) {
43 $blog = new WebsitePage($db);
44 $blog->fetch($id);
45
46 $selectedPosts[] = array(
47 'id' => $blog->id,
48 'title' => $blog->title,
49 'description' => $blog->description,
50 'date_creation' => $blog->date_creation,
51 'image' => $blog->image,
52 );
53 }
54
55 print json_encode($selectedPosts);
56} else {
57 print json_encode(array('error' => 'Invalid request'));
58}
$id
Definition account.php:48
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.