A "CMS" for a one-page site? [closed] - content-management-system

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm going to build a site for a client that consists of only one page. The page has only one div with editable content; the rest can be hard-coded in a template file.
The client wants CMS-like behavior: logging in on the site and editing that single piece of text (preferably inline). I usually build larger sites with Drupal, but that would be overkill for something simple like this.
Does anybody know of a good (open source) solution for a site like this?

It shouldn't be a large job to code this from scratch. All you need is admin.php with some kind of authentication and one form. I timed myself and made this in 7 minutes:
Login and logout
if(isset($_GET['login'])) {
// Check user credentials from db or hardcoded variables
if($_POST['username'] == 'user123' && $_POST['password'] == 'pass123') {
$_SESSION['logged'] = true;
} else {
$loginerror = 'Invalid credentials';
}
}
if(isset($_GET['logout'])) {
$_SESSION = array();
session_destroy();
}
Login form
if(!isset($_SESSION['logged']) || $_SESSION['logged'] !== true): ?>
<form method="post" action="admin.php?login">
<?php if(isset($loginerror)) echo '<p>'.$loginerror.'</p>'; ?>
<input type="username" name="username" value="<?php isset($_POST['username']) echo $_POST['username']; ?>" />
<input type="password" name="password" />
<input type="submit" value="Login" />
</form>
<?php endif;
Actual admin area
if(isset($_SESSION['logged']) && $_SESSION['logged'] === true):
// Save contents
if(isset($_GET['save'])) {
file_put_contents('contents.txt', $_POST['contents']);
}
// Get contents from db or file
$contents = file_get_contents('contents.txt');
?>
Logout
<form method="post" action="admin.php?save">
<textarea name="contents"><?php echo $contents; ?></textarea>
<input type="submit" value="Save" />
</form>
<?php endif;
Just combine those segments to get the full code. This code snippet has authentication, logout functionality and saves the contents of a textarea in a file. Alternatively you could change this so that users and content resides in database.
Personally, it would have taken longer for me to find an appropriate lightweight CMS and configure it to work.

Ok, here is my version of the CMS. You can find all my files here in a zip archive: http://chechi.be/midas/simple-cms.zip.
This is the admin page:
<?php session_start();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>CMS</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div id="main">
<h1>CMS</h1>
<?php
if (empty($_POST) && isset($_GET['action'])) {
$action = $_GET['action'];
switch ($action) {
case 'logout':
session_unset();
session_destroy();
break;
}
}
if (!isset($_SESSION['user'])) {
$user = '';
$pass = '';
if (isset($_POST['login'])) {
$user = strtolower(trim($_POST['user']));
$pass = $_POST['pass'];
$errors = array();
if ($user == '' || $user != 'admin') {
$errors['user'] = '';
}
if ($pass == '' || $pass != '123456') {
$errors['pass'] = '';
}
if (empty($errors)) {
$_SESSION['user'] = $user;
} else {
echo '<p class="error">Please fill in your correct ';
if (isset($errors['user']))
echo 'username';
if (count($errors) == 2)
echo ' and ';
if (isset($errors['pass']))
echo 'password';
echo '.</p>', "\n";
}
}
}
if (isset($_SESSION['user'])) {
$user = $_SESSION['user'];
?>
<div id="headertext">
<p class="l">You are logged in as <strong><?php echo $user?></strong>.</p>
<p class="r">Logout</p>
</div>
<?php
if (isset($_POST['edit'])) {
if (file_put_contents('homecontent.txt', $_POST['homecontent']) !== FALSE)
echo '<p class="succes">Your changes are saved.</p>', "\n";
}
$homecontent = file_get_contents('homecontent.txt');
?>
<form method="post" action="">
<p>Here you can edit your homepage text:</p>
<textarea name="homecontent" id="homecontent" rows="20" cols="55"><?php echo $homecontent?></textarea>
<p><button type="submit" name="edit">Save changes</button></p>
</form>
<?php } else {?>
<form method="post" action="" id="login">
<p>
<label for="user">Username:</label><input type="text" name="user" id="user" value="<?php echo $user?>" />
</p>
<p>
<label for="pass">Password:</label><input type="password" name="pass" id="pass" value="<?php echo $pass?>" />
</p>
<p>
<button type="submit" name="login">Login</button>
</p>
</form>
<?php }?>
</div>
</body>
</html>

I really love Zimplit for projects that consist of a "a very few pages". They have a brilliant concept of a really minimalistic WYSIWG-editor that edits the entire page (not just the contents). And no database, or other cruft.
I found that many clients can really grok the concept immediately.

Two solutions come to my mind:
WonderCMS is the smallest CMS you can imagine (it's only a 11KB download). Its concept is similar to what some others have posted: Just a login, a textarea and some minimal extra settings. You can also add pages and build a simple navigation, but it's easy to prevent that.
OneFileCMS is not really a CMS (but even smaller than WonderCMS: 6KB). It's an online file manager with a simple text editor, which consists of one single PHP file. That way you can build your "template" and include one file in a subfolder which contains the editable content. Just put the OneFileCMS into that folder and it can handle the login and editing.

Try CushyCMS.

If you want a super simple one page CMS using a flat text file I would recommend BonoboCMS. It is basically what you were talking about, and it has support for Markdown.

Here is one, it's perfect for small sites: One Page CMS.
I have used it for years now. WYSIWYG is based on TinyCMS but I use nicedit.

Have a look at TiddlyWiki. I'm not sure if this have login facilities etc, but It has all the major features of a small CMS.

Use Wordpress and create a simple theme. Wordpress has article history too so it's easy to go back if a mistake is made and so on.

One File CMS? AutoCMS is a cms with this proposal , only 10kb and two files, index.php (call to class) and autocms.php (php class), but, if should you can put de index.php content in autocms.php , and get one file cms, is very fast with de minimal requeriments to get a place on internet, try is opensoure www.ventics.com/autocms , BSD license to learn and enjoy

Try Atomic CMS which is free and open source ASP.NET MVC content management system. It's ideal solution for one page sites, easy to install, support and understand...
Atomic CMS - content management system

ths is also very simple to setup and use http://www.tero.co.uk/scripts/onepagecms.php

I'd personally use Perch CMS: https://grabaperch.com/ or Unify: http://unify.unitinteractive.com/

I like Wordpress. It's techincally "blogging" software, but it's very easy to extend into a nice small CMS.

It's easy. You can code one in 10 minutes (or ask me).
Just a page with and admin file for editing text.txt.

Related

GTM - Track all downloads except certain classes

I currently have a trigger in GTM that tracks when certain documents are downloaded, such as pdfs, xlsx, png, docx, jpg... etc..
This is setup to track on the entire site, however I have a specific section that I don't want tracked by this catch all.
I've been trying to add an exception that says if a download link contains the class "Library_Download" then don't track it under the catch all trigger.
I'm trying to bring more clarity to what types of files are being downloaded.
I have tried adding exceptions to the tag, or adding validation to the trigger that and I seem to be missing something.
Catch All Trigger
Trigger Type: Click - Just Links
Trigger Fires On: Element URL Path - matches RegEx
\.(pdf|xlsx|png|docx|jpg|jpeg|zip|pat|dwg)$
How do I not count any link that contains the class "Library_Download" Or is there another way I should have them omitted?
I've created the following trigger and added it as an exception to the tag but it didn't work.
Trigger Type: Custom Event
Event name: \* (Enabled regex matching)
Trigger Fires on: Click Class - contains - "Library_booking"
Nov 21 Edit
So to clarify a bit more with HTML. Below is what I'm currently using for my library_download link. I'm currently only concerned with the pdfdownload.pdf
<div class="resource_row">
<div class="resource_item large <?php echo $post->post_name; ?>" data-filter-item data-filter-name="<?php echo $post->post_name; ?>">
<a href="www.librarywebsite.com/librarypage/" ><?php the_post_thumbnail('medium'); ?></a>
<p><?php the_title(); ?></p>
<ul class="resource_icons">
<li><img src="<?php bloginfo('stylesheet_directory'); ?>/img/icon-download.png" alt="Download PDF" /></li>
<li><img src="<?php bloginfo('stylesheet_directory'); ?>/img/icon-library.png" alt="library" /></li>
</ul>
</div>
</div>
This is how a regular link would look like (the only thing that's changed is I have removed the class Library_Download
<div class="resource_row">
<div class="resource_item large <?php echo $post->post_name; ?>" data-filter-item data-filter-name="<?php echo $post->post_name; ?>">
<a href="www.librarywebsite.com/librarypage/" ><?php the_post_thumbnail('medium'); ?></a>
<p><?php the_title(); ?></p>
<ul class="resource_icons">
<li><img src="<?php bloginfo('stylesheet_directory'); ?>/img/icon-download.png" alt="Download PDF" /></li>
<li><img src="<?php bloginfo('stylesheet_directory'); ?>/img/icon-library.png" alt="library" /></li>
</ul>
</div>
</div>
Like I've mentioned my catch all trigger currently get's triggered on every single PDF download, I just want to omit the links that have class "Library_download".
In my opinion you made a mistake in your regex in "Custom Event" exclusion rule (that's why this rule doesn't work). You have "\*" (with regex matching checked). Try to change regex to:
.*
This will match every event (and then of course preserve this: Trigger Fires on: Click Class - contains - "Library_booking").
In your case regex like this: "\*" will match only to event strictly named as "*" (star)

Getting HTML of a Cake PHP form

I am creating a form using Cake PHP. Is there any way to retrieve the basic HTML of the created form. For example,if we use Form Helper, we can create form using PHP itself. But now, I need only the html part of the created form for other use. Is it possible to retrieve it??
For example, say if I give input form like,
<?php
echo $this->Form->create('User');
echo $this->Form->input('email');
echo $this->Form->end('Save');
?>
I need output like this
<form action="index.html">
<input type="email" />
<input type="submit" value="Save" />
</form>
I can even create seperate function for attaining this objective. But I would like to know, if there is any other method for achieving this output
you can store FormHelper output in a string variable
<?php
$html_string = '';
$html_string .= $this->Form->create('User');
$html_string .= $this->Form->input('email');
$html_string .= $this->Form->end('Save');
?>
and then use your string elsewhere. But I'm not sure this is what you're searching for.
If I understand the question correctly, you want to use the form you created on another part of your site?
If that is the case, I would put the form itself in an Element and then call the Element wherever I wanted the form.
View/Elements/form.ctp
<?php
echo $this->Form->create('User');
echo $this->Form->input('email');
echo $this->Form->end('Save');
?>
Then in any view on your site you can call the Element using:
<?php echo $this->element('form');?>

Form action duplicates url

new to CI and for some reason the form submits to a wrong url.
the result is : http://localhost/ci/index.php/subjects/localhost/ci/index.php/do_upload
and can't understand why.
This is the html code :
echo form_open_multipart('do_upload');
?>
<input type="file" name="files[]" id="fileupload"
style="position:absolute; top:-200px" multiple />
<input type="submit" id="uploadFile" style="position:absolute; top:-200px" />
<?php echo form_close(); ?>
Any help?
I've also tried to write subjects/do_upload on form open, same thing.
Check your config for base_url and site_url
Leave them '' blank.

View Helper, Partial View or Something Else

I am new to Zend Framework and I have a question about something I am trying to do.
The main content of most pages of the application that I am working on will consist of 1 or more div elements that need to be styled the same.
Here is an example of the HTML that I want to generate:
<div id='admin-locations' class='panel'>
<header class="panel-header">
<h2>Locations</h2>
</header>
<div class='panel-content'>
<div id='locations-table' class='google-vis-table'></div>
<form id='locations'>
...
</form>
</div>
</div>
I know I can easily do this by pushing the form to my view script in my controller then adding this code to my controller.
<div id='admin-locations' class='panel'>
<header class="panel-header">
<h2>Locations</h2>
</header>
<div class='panel-content'>
<div id='locations-table' class="google_vis_table"></div>
<?php
echo $this->formLocations;
?>
</div>
</div>
But that is not DRY.
The example I used here has a Google Visualization Table and a Zend Form in it's content. Sometimes the panels will need to contain a form. Sometimes they won't, so I don't think form decorators are the way to go. So basically, the id of the panel, the panel header text and the content of div class='panel-content' need to be dynamic. Everything else will stay the same from panel to panel.
What is my best option here?
You might want to consider using partials:
http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.partial
For example, you could have an admin-locations.phtml partial that contains:
<div id='admin-locations' class='panel'>
<header class="panel-header">
<h2>Locations</h2>
</header>
<div class='panel-content'>
<div id='locations-table' class="google_vis_table"></div>
<?php echo $this->form; ?>
</div>
</div>
Now you can simply repeatedly call the partial within a view, with or without supplying a form:
...
echo $this->partial('admin-locations.phtml');
echo $this->partial('admin-locations.phtml', array('form' => $this->yourForm);
echo $this->partial('admin-locations.phtml');
...
Hope this helps.

Zend controller/view newbie puzzle: $_GET & $_POST empty - on receipt from HTML form within view

Zend newbie here ... And just to make it better, my mission is to build on top of someone else's pre-existing Zend site.
(BTW: zf show version --> Zend Framework Version: 1.11.1 -- I seem to have Zend_Form).
Here's the curious bit. All the forms are built in HTML within views. They seem to work, although I can't figure out how -- especially given what I am seeing.
I followed the convention and created a view for a test form and wrote the form:
<form action="<?php echo $this->url(array('controller'=>'ControllerName','action'=>'submit'));?>" method="post" style="margin-left:20px">
<p class="bold setmgr">Your email here:</p>
<div class="field">
<input class="text" type="text name="custEmail"/>
</div>
<div class="field">
<input class="button" value="Submit and be free!" type="submit"/>
</div>
</form>
The submitAction member in the controller is firing correctly. No problem.
But ALL the places I could look for the POST data appear to be empty!
echo "obj custEmail = [" . $this->_request->getPost('custEmail') . "]\n";
echo "GET custEmail = [" . $_GET['custEmail'] . "]\n";
echo "POST custEmail = [" . $_POST['custEmail'] . "]\n";
if ($this->_request->isPost()) {
$data = $this->_request->getPost();
Zend_Debug::dump($data);
}
They all produce nothing.
I'd be much obliged for a solution or even a clue about what is going wrong.
Thanks for reading.
Your form is not in the correct format.As it's PHP you can use form like this or you can even generate a ZEND_FORM(which is profound way to do it).It's always a good practise to work around with ZEND_FORM.If you still want to use this and the go by your way,here is th snippet I modified for you.
I am modifying the Code for you.Your View should have this form in it;
<form action="" method="post" style="margin-left:20px">
<p class="bold setmgr">Your email here:</p>
<div class="field">
<input class="text" type="text" name="custEmail"/>
</div>
<div class="field">
<input class="button" value="Submit and be free!" type="submit" name="submit"/>
</div>
</form>
<?php
echo $this->custEmail;
?>
Now write the following one on your ACTIOn,i.e. submitAction;
public function submitAction()
{
if ($this->getRequest()->isPost())
{
$custEmail = $this->getRequest()->getPost('custEmail');
echo $custEmail;
$this->view->custEmail = $custEmail;
}
}
Now check if it works for you or not.
Create a form using Zend_Form. When ZF already has a way to create forms, you should use that. Your method is like a hack and is not a recommended way to do things.
Check here on how to create a Zend_Form
http://framework.zend.com/manual/en/zend.form.html