2020-08-24, 05:51:41
Hi Bigin,
The picture tuto example works very well.
But what I want is just a backend.php to add and delete pictures, without the login.php and the functions.php
It works as long as I have this single backend.php and the framework folder both in the root of GS.
Without the login.php and functions.php this is my working backend.php:
So far so good.
But it goes wrong when I move the backend.php out of the GS root, to the folder root/test/
So when I have the backend.php inside: /test/backend.php
in backend.php I adapt include 'framework/imanager.php'; to => include '../framework/imanager.php';
But this doesn't seem to work correctly.
When I move the folder framework also to root/test/ then it starts to work again correct.
But I want the folder framework to stay in the root and only move the backend.php
to another location inside GS.
For example I would like to create a page inside GS with the name backend and assign a template file to it with the name backend.php. This template file would hold the backend php code and the page backend would only be accessible with http://domain.com/backend/ for as long as I need to add or delete pictures.
What am I doing wrong ?
It seems that adapting include 'framework/imanager.php'; to the new location is not enough.
The picture tuto example works very well.
But what I want is just a backend.php to add and delete pictures, without the login.php and the functions.php
It works as long as I have this single backend.php and the framework folder both in the root of GS.
Without the login.php and functions.php this is my working backend.php:
Code:
<?php
include 'framework/imanager.php';
$gallery = $imanager->getCategory('name=Gallery');
$timestamp = time();
$item = $gallery->getItem(1);
if(!$item) {
$item = new \Imanager\Item($gallery->id);
}
if($imanager->input->post->action == 'save') {
// It is a New Item, before you can save the images you
// should always save the item itself first, because it
// should create the directories and the important ID's first.
$item->save();
$dataSent = array(
'file' => $imanager->input->post->position_images,
'title' => $imanager->input->post->title_images,
'timestamp' => $imanager->input->get->timestamp
);
// Set input value
if($item->set('images', $dataSent)) {
$item->save();
} else {
echo 'Error: The field value could not be set';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Backend</title>
<meta name="description" content="Just a simple login Form">
<!-- Mobile-friendly viewport -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<meta name="author" content="J.E">
</head>
<body>
<main role="main">
<?php
$imanager->fieldMapper->init($gallery->id, true);
$field = $gallery->getField('name=images');
$widget = new \Imanager\FieldFileupload();
echo '<form action="./test.php" method="post">';
$widget->set('url', 'framework/');
$widget->set('action', "framework/imanager/upload/server/php/index.php");
$widget->set('id', $field->name);
$widget->set('categoryid', $field->categoryid);
$widget->set('itemid', isset($item->id) ? $item->id : null);
$widget->set('timestamp', $timestamp);
$widget->set('fieldid', $field->id);
$widget->set('configs', $field->configs, false);
$widget->set('name', $field->name);
echo $widget->render();
echo '<input type="hidden" name="action" value="save">';
echo '<button type="submit">Save</button>';
echo '</form>';
?>
</main>
<footer role="contentinfo">
<small>Copyright ©
<time datetime="<?php echo date('Y'); ?>"><?php echo date('Y'); ?></time> Ehret Studio</small>
</footer>
<script src="js/jquery-1.12.4.min.js"></script>
<script src="js/jquery-ui.min.js"></script>
<?php echo $widget->renderJsBlock(); ?>
<?php echo $widget->renderJsLibs(); ?>
</body>
</html>
So far so good.
But it goes wrong when I move the backend.php out of the GS root, to the folder root/test/
So when I have the backend.php inside: /test/backend.php
in backend.php I adapt include 'framework/imanager.php'; to => include '../framework/imanager.php';
But this doesn't seem to work correctly.
When I move the folder framework also to root/test/ then it starts to work again correct.
But I want the folder framework to stay in the root and only move the backend.php
to another location inside GS.
For example I would like to create a page inside GS with the name backend and assign a template file to it with the name backend.php. This template file would hold the backend php code and the page backend would only be accessible with http://domain.com/backend/ for as long as I need to add or delete pictures.
What am I doing wrong ?
It seems that adapting include 'framework/imanager.php'; to the new location is not enough.