PDA

View Full Version : Mys 1.3.4 News System


IntoRain
02-14-2014, 03:07 PM
Hello! I know some people wanted a system like this so I decided to make one. This mod will allow you to post news to your users - you can create, edit and delete news. Using javascript, it has also a simple pagination system that will show a certain amount of news per page. Users can comment on each news post if you allow comments. News can be posted or saved as drafts to be edited later, admins can see drafts on the site but normal users can't. You can control users' comments: edit, delete and allow/disallow.

IMPORTANT:
If you have your site installed in a subfolder or if you changed page links, you might need to change some of the URLs used in the code. Please address to this post (http://mysidiaadoptables.com/forum/showpost.php?p=29201&postcount=11).

IMPORTANT:
It's not possible to send PM's to all users (selecting that option does nothing) about the updates yet!

IMPORTANT:
At the bottom of the post, there's a .rar you can download with the 4 new files (so you won't need to create the files yourself)

Part 0: The looks
After adding this, you should get something like this:
All news (http://i.imgur.com/0hH3x4A.png)
Showing a news and its comments (http://i.imgur.com/s2nqUZ2.png)
Showing a specific news that doesn't allow comments (http://i.imgur.com/XQJRjOQ.png)

And the acp:
Control all news (http://i.imgur.com/aQG8ULo.png)
Create news ones (http://i.imgur.com/DMWuaVQ.png)

Part 1: The database

The first step to make this work is create two tables on your website's database. For this go to phpMyAdmin, select your database and wait for everything to load on the left.
Scroll down and you will see "Create table". You will be creating two tables: news and newscomments (with whatever prefix your database has)
In this page, create 7 columns for the news and 5 for the newscomments (click Add columns -> Execute, to add more lines) with the exact info you will see on the images linked below (it's in portuguese, but the order should be the same) - be careful with the names!! And make sure the ID is set to AUTO_INCREMENT (A_I).
After this, your two tables should show up on the left

TUTORIAL IMAGES:
News table and (http://i.imgur.com/uECJR2s.png)
Newscomments table (http://i.imgur.com/tY4WeqX.png)

Part 2: The objects
Go to your file manager now and let's start coding!
Inside the classes folder, create a file named class_news.php and add this content:

<?php

use Resource\Native\Object;
use Resource\Native\Arrays;

class News extends Object {


private $id;
private $user;
private $title;
private $content;
private $date;
private $posted;
private $comments;
private $allowcomment;

public function __construct($id){
$mysidia = Registry::get("mysidia");
$whereClause = "id = '{$id}'";
$row = $mysidia->db->select("news",array(),$whereClause)->fetchObject();
if(!is_object($row)) throw new NoPermissionException("News doesn't exist");
foreach($row as $key => $val){
$this->$key = $val;
}
$this->comments = $mysidia->db->select("newscomments",array("id"),"newsID = {$this->id} ORDER BY date,id");
}

public function getID(){
return $this->id;
}

public function getUser(){
return $this->user;
}

public function getUserObject(){
$mysidia = Registry::get("mysidia");
$user = new Member($this->user);
return $user;
}
public function getTitle(){
return $this->title;
}

public function getContent(){
return $this->content;
}

public function getDate(){
return $this->date;
}

public function getPosted(){
return $this->posted;
}

public function getAllowComment(){
return $this->allowcomment;
}

public function changeAllowComment($allow){
$mysidia = Registry::get("mysidia");
if($this->allowcomment != $allow){
$this->allowcomment = $allow;
$mysidia->db->update("news",array("allowcomment" => $this->allowcomment),"id = {$this->id}");
}

}

public function addComment($content,$date,$user){
$mysidia = Registry::get("mysidia");
$mysidia->db->insert("newscomments",array("comment" => $this->format($content), "date" => $date, "userID" => $user, "newsID" => $this->id));
$this->comments = $mysidia->db->select("newscomments",array("id"),"newsID = {$this->id} ORDER BY date,id");
}

private function format($text){
$text = html_entity_decode($text);
$text = stripslashes($text);
$text = str_replace("rn","",$text);
return $text;
}

public function saveDraft(){
$mysidia = Registry::get("mysidia");
$todayDate = $this->todayDate();
if($this->date != $todayDate) $this->newDate($todayDate);
$this->posted = "no";
$mysidia->db->update("news",array("posted" => $this->posted),"id = {$this->id}");
}

public function post(){
$mysidia = Registry::get("mysidia");
$todayDate = $this->todayDate();
if($this->date != $todayDate) $this->newDate($todayDate);
$this->posted = "yes";
$mysidia->db->update("news",array("posted" => $this->posted),"id = {$this->id}");
}

public function editContent($content){
$mysidia = Registry::get("mysidia");
$this->content = $content;
$mysidia->db->update("news",array("content" => $this->content),"id = {$this->id}");
}

public function editTitle($title){
$mysidia = Registry::get("mysidia");
$this->title = $title;
$mysidia->db->update("news",array("title" => $this->title),"id = {$this->id}");
}

public function todayDate(){
$dateTime = new DateTime;
$date = $dateTime->format('Y-m-d H:i:s');
return $date;
}
public function newDate($date){
$mysidia = Registry::get("mysidia");
$this->date = $date;
$mysidia->db->update("news",array("date" => $this->date),"id = {$this->id}");
}

public function getCommentNumber(){
$count = $this->comments->rowCount();
return $count;
}

public function getComments(){
return $this->comments;
}

}

?>

In the same folder, create a class_newscomments.php file with these contents:

<?php

use Resource\Native\Object;
use Resource\Native\Arrays;

class NewsComments extends Object {


private $id;
private $userID;
private $newsID;
private $comment;
private $date;

public function __construct($id){
$mysidia = Registry::get("mysidia");
$whereClause = "id = '{$id}'";
$row = $mysidia->db->select("newscomments",array(),$whereClause)->fetchObject();
if(!is_object($row)) throw new NoPermissionException("News comment doesn't exist");
foreach($row as $key => $val){
$this->$key = $val;
}
}

public function getID(){
return $this->id;
}

public function getUser(){
return $this->userID;
}

public function getUserObject(){
$mysidia = Registry::get("mysidia");
$user = new Member($this->userID);
return $user;
}

public function getNews(){
return $this->newsID;
}

public function getNewsObject(){
$mysidia = Registry::get("mysidia");
$news = new News($this->newsID);
return $news;
}

public function getContent(){
return $this->comment;
}

public function getDate(){
return $this->date;
}

public function todayDate(){
$dateTime = new DateTime;
$date = $dateTime->format('Y-m-d H:i:s');
return $date;
}

public function setContent($content){
$mysidia = Registry::get("mysidia");
$this->content = $content;
$mysidia->db->update("newscomments",array("comment" => $this->content),"id = {$this->id}");
}


}

?>

Part 3: Displaying news on your site!
Now go to the main folder (where the files like account.php and some folders like admincp and classes are) and create the news.php file with these contents:

<?php

use Resource\Native\String;
use Resource\Native\Float;
use Resource\Collection\ArrayList;

class NewsController extends AppController{

public function __construct(){
parent::__construct("member");
}

public function index(){

$mysidia = Registry::get("mysidia");
$allnews = $mysidia->db->select("news",array("id"),"posted = 'yes' ORDER BY date DESC");
$count = $allnews->rowCount();
if($count == 0) throw new NoPermissionException("There are currently no news to display.");
$this->setField("allnews",new DatabaseStatement($allnews));

}

public function view(){
$mysidia = Registry::get("mysidia");
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}

$parts = Explode('/', $pageURL);
$id = $parts[count($parts) - 1];
$news = new News($id);

if($news->getPosted() == "no")
{
if($mysidia->usergroup->getpermission("canmanagecontent") != "yes")//rootadmins, admins and artists
{
throw new NoPermissionException("This message doesn't exist or isn't yet viewable.");
}
}

/*include_once("inc/ckeditor/ckeditor.php");
$editor = new CKEditor;
$editor->basePath = '../../inc/ckeditor/';
$editor2 = $editor->editor("commentcontent", "Write here");
$this->setField("editor",new DataObject($editor2));*/

if($mysidia->input->post("submit")){
if(!$mysidia->input->post("commentcontent"))
throw new BlankFieldException("No content or content has an invalid character.");
if($mysidia->usergroup->getpermission("canadopt") != "yes")
throw new NoPermissionException("No permission");
if($news->getPosted() == "no")
throw new NoPermissionException("Can't post comments to drafts.");
if($this->commentAlreadyExists($mysidia->input->post("commentcontent"),$id))
throw new NoPermissionException("Oops, seems like you tried to post the same comment.");
if($news->getAllowComment() == "no")
throw new NoPermissionException("No comments allowed on this news post.");
}

$news = new News($id);
$this->setField("news",$news);

}

private function commentAlreadyExists($comment, $newsID){
$mysidia = Registry::get("mysidia");
$count = $mysidia->db->select("newscomments",array("id"),"comment = '{$comment}' and newsID = '{$newsID}' LIMIT 1")->rowCount();
return ($count > 0);
}

}
?>

Next, in the folder view, create newsview.php with these contents:

<?php

class NewsView extends View{

public function index(){

$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("News");


$allnews = $this->getField("allnews")->get();
$count = $allnews->rowCount();
$pagesTotal = ceil($count/2);
$document->add(new Comment("<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script>
<script>
var current = 1;
var max = current * 2;
var min = 1;

$(document).ready(function(){

$('fieldset+br').hide();
$('[name^=news]').hide();

for(var i = min; i <= max; i++)
{
$('[name=news' + i +']').show();
$('[name=news' + i +']+br').show();
}

$('span[id^=page]').click(function(){
current = $(this).html();
max = current * 2;
oldMax = (current - 1) * 2;

min = oldMax + 1;

$('fieldset+br').hide();
$('[name^=news]').hide();

for(var i = min; i <= max; i++)
{
$('[name=news' + i +']').show();
$('[name=news' + i +']+br').show();
}


});
});
</script>"));
$document->add(new Comment("<span class='pages'><center>"));
for($page = 1; $page <= $pagesTotal; $page++)
{
$document->add(new Comment("<span id='page{$page}' class='page'>{$page}</span> | ",FALSE));
}


$document->add(new Comment("</center></span><br><div id='news' class='news'>"));
$index = 0;
while($news = $allnews->fetchColumn())
{
$newsObj = new News($news);
$index++;
$newsField = new Fieldset("news$index");
$comments = $newsObj->getCommentNumber();
$newsField->add(new Comment("<span class='date'>Date: {$newsObj->getDate()}</span><br>",FALSE));
$newsField->add(new Comment("<span class='title'>{$newsObj->getTitle()}</span>",FALSE));
$newsField->add(new Comment("<span class='author'>by <a href='/profile/view/{$newsObj->getUserObject()->getUsername()}' target='_blank'>{$newsObj->getUserObject()->getUsername()}</a></span>",FALSE));
$newsField->add(new Comment("<span class='comment'><a href='/news/view/{$newsObj->getID()}'>Comments({$comments})</a></span><br>",FALSE));
$newsField->add(new Comment("<span class='content'><img class='authorimg' src='{$newsObj->getUserObject()->getprofile()->getavatar()}'>{$newsObj->getContent()}</span>",FALSE));

$document->add($newsField);
}

$document->add(new Comment('</div>'));
}

public function view(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$news = $this->getField("news");
($news->getPosted() == "yes")? $newsState = " ":$newsState = "(draft)";
$newsName = $news->getTitle();
$newsContent = $news->getContent();
$newsAuthor = $news->getUserObject()->getUsername();
$newsDate = $news->getDate();
$newsComments = $news->getComments();
$document->setTitle("news");

$document->add(new Comment("<div id='news' class='news'>"));
$newsField = new Fieldset("news");
$newsField->add(new Comment("<span class='date'>Date: {$newsDate}</span><br>",FALSE));
$newsField->add(new Comment("<span class='title'>{$newsName}{$newsState}</span>",FALSE));
$newsField->add(new Comment("<span class='author'>by <a href='/profile/view/{$newsAuthor}' target='_blank'>{$newsAuthor}</a></span>",FALSE));
$newsField->add(new Comment("<span class='content'><p><img class='authorimg' src='../../{$news->getUserObject()->getprofile()->getavatar()}'>{$newsContent}<p></span>",FALSE));
$document->add($newsField);
$document->add(new Comment("<h1>comments</h1>",FALSE));

if($mysidia->input->post("submit")){
$todayDate = new DateTime;
$date = $todayDate->format('Y-m-d H:i:s');
$content = $mysidia->input->post("commentcontent");
$user = $mysidia->user->uid;
$newsID = $news->getID();

$news->addComment($content,$date,$user);
$document->add(new Comment("<b>Successfully added comment.</b>",FALSE));

}

$newsComments = $this->getField("news")->getComments();
if($newsComments->rowCount() != 0){
while($commentID = $newsComments->fetchColumn()){
$comment = new NewsComments($commentID);
$commentField = new Fieldset("comment{$comment->getID()}");
$commentField->add(new Comment("<span class='cdate'>Date: {$comment->getDate()}</span><br>",FALSE));
$commentField->add(new Comment("<span class='cauthor'>by <a href='/profile/view/{$comment->getUserObject()->getUsername()}' target='_blank'>{$comment->getUserObject()->getUsername()}</a></span>",FALSE));
$commentField->add(new Comment("<span class='ccontent'><p><img src='../../{$comment->getUserObject()->getprofile()->getavatar()}'>{$comment->getContent()}<p></span>",FALSE));
$document->add($commentField);
}
}
else{
$document->add(new Comment("No comments yet."));
}

if($news->getAllowComment() == "yes"){
$commentForm = new Form("comment","","post");
$commentForm->add(new TextArea("commentcontent", "", 4, 50));
$commentForm->add(new Button("Submit","submit","submit"));
$document->add($commentForm);
$document->add(new Comment('</div>'));
}
else{
$document->add(new Comment("<b>This page doesn't allow any more comments.</b>"));
}
}


}
?>

With this code, it will display two news per page. Change these values to change it to whatever you want (in the same file):

Click here (http://i.imgur.com/kumkVVp.png)


Now you will be able to access [yoursite]/news page and see that there aren't any news there. (Don't forget to add a /news link to your site! I added mine under Home).

Part 4: The AdminCP
Now let's add the adminCP pages so you can control all news and comments.

Inside the lang folder, there's an admincp folder. Create a lang_news.php file with these contents:


<?php

//Language variables used for AdminCP/News Page

$lang['default_title'] = "News";

?>

Inside the admincp folder create a news.php file with these contents:

<?php

class ACPNewsController extends AppController{

const PARAM = "pageurl";
private $editor;

public function __construct(){
parent::__construct();
include_once("../inc/ckeditor/ckeditor.php");
$mysidia = Registry::get("mysidia");
$this->editor = new CKEditor;
$this->editor->basePath = '../../../inc/ckeditor/';
if($mysidia->usergroup->getpermission("canmanagecontent") != "yes"){
throw new NoPermissionException("You do not have permission to manage users.");
}
}

public function index(){
parent::index();
$mysidia = Registry::get("mysidia");
$allnews = $mysidia->db->select("news",array("id"),"");
$this->setField("news",new DatabaseStatement($allnews));

}

public function viewcomments(){
$mysidia = Registry::get("mysidia");
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
$parts = Explode('/', $pageURL);
$id = $parts[count($parts) - 1];

$news = new News($id);
$this->setField("news",$news);


if($mysidia->input->post("submit2")){
$news = new News($id);
$this->setField("news2",$news);
}

}

public function editcomment(){
$mysidia = Registry::get("mysidia");
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}

$parts = Explode('/', $pageURL);
$id = $parts[count($parts) - 1];

$newsComment = new NewsComments($id);
$comment = $this->format($newsComment->getContent());

if($mysidia->input->post("submit")){
if(!$mysidia->input->post("commentcontent"))
throw new BlankFieldException("No content");
else
$comment = $this->format($newsComment->getContent());
}

$this->setField("newscomments",$newsComment);
$editor2 = $this->editor->editor("commentcontent",$comment);
$this->setField("editor",new DataObject($editor2));

}

public function edit(){
$mysidia = Registry::get("mysidia");
if($mysidia->input->post("submit")){
if(!$mysidia->input->post("newstitle")) throw new BlankFieldException("No title");
if(!$mysidia->input->post("pagecontent")) throw new BlanKFieldException("No content");
}

$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}

$parts = Explode('/', $pageURL);
$id = $parts[count($parts) - 1];

$news = new News($id);
$this->setField("news",$news);
$editor = $this->editor;
$this->setField("editor",new DataObject($editor));
}

public function create(){
$mysidia = Registry::get("mysidia");
if($mysidia->input->post("submit")){
if(!$mysidia->input->post("newstitle")) throw new BlankFieldException("No title");
if(!$mysidia->input->post("pagecontent")) throw new BlanKFieldException("No content");
}

$editor = $this->editor->editor("pagecontent", "");
$this->setField("editor",new DataObject($editor));
}

private function format($text){
$text = html_entity_decode($text);
$text = stripslashes($text);
$text = str_replace("rn","",$text);
return $text;
}
}
?>

Now inside the folder admincp/view create a file newsview.php with these contents:

<?php

use Resource\Native\String;
use Resource\Collection\LinkedList;
use Resource\Collection\LinkedHashMap;

class ACPNewsView extends View{

private $editor;

public function index(){
//parent::index();
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("Manage News And Comments");

$pagesTable = new TableBuilder("news");
$pagesTable->setAlign(new Align("center", "middle"));

$pagesTable->buildHeaders("News Title", "Author", "Date", "Edit", "Publish/Save", "Delete", "View Comments", "View News");

$allnews = $this->getField("news")->get();

if($mysidia->input->post("submit")){
$id = $mysidia->input->post("submit");
$newsObj = new News($id);
$newsObj->saveDraft();
$document->add(new Comment("<b>Successfully saved news as draft</b>",TRUE));
}

if($mysidia->input->post("submit1")){
$id = $mysidia->input->post("submit1");
$newsObj = new News($id);
$newsObj->post();
$document->add(new Comment("<b>Successfully added and published news.</b>",TRUE));
}

if($mysidia->input->post("submit2")){
$id = $mysidia->input->post("submit2");
$newsObj = new News($id);
$document->add(new Comment("Are you sure you wish to delete this news?",TRUE));
$form = new Form("title","","post");
$form->add(new Button("Yes","submit5",$id));
$document->add($form);

}
if($mysidia->input->post("submit5")){
$id = $mysidia->input->post("submit5");
$mysidia->db->delete("news","id = {$id}");
$document->add(new Comment("Successfully deleted news",TRUE));
$allnews = $mysidia->db->select("news",array("id"),"");
}

while($news = $allnews->fetchColumn()){
$newsObj = new News($news);
$cells = new LinkedList;
($newsObj->getPosted() == "yes")? $draft = "":$draft = "(draft)";
$title = "{$newsObj->getTitle()} {$draft}";
$cells->add(new TCell($title));
$cells->add(new TCell($newsObj->getUserObject()->getUsername()));
$cells->add(new TCell($newsObj->getDate()));
$cells->add(new TCell(new Link("admincp/news/edit/{$news}","Edit")));

$form = new Form("title","","post");
$form->add(new Button("Save As Draft","submit",$news));
$form2 = new Form("title","","post");
$form2->add(new Button("Publish","submit1",$news));
$form3 = new Form("title","","post");
$form3->add(new Button("Delete","submit2",$news));

($newsObj->getPosted() == "yes")? $cells->add(new TCell($form)) : $cells->add(new TCell($form2));
$cells->add(new TCell($form3));
$cells->add(new TCell(new Link("admincp/news/viewcomments/{$news}","View Comments")));
$cells->add(new TCell(new Link("news/view/{$news}","View News On Site")));
$pagesTable->buildRow($cells);
}

$document->add($pagesTable);
$document->add(new Comment("<a href='/admincp/news/create'>Create</a>",TRUE));

}

public function viewcomments(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("editing comments");
$news = $this->getField("news");

$newsComments = $news->getComments();


$pagesTable = new TableBuilder("news");
$pagesTable->setAlign(new Align("center", "middle"));

$pagesTable->buildHeaders("Author", "Date", "Content", "Edit", "Delete");

if($mysidia->input->post("submit")){
$document->add(new Comment("Are you sure you wish to delete this comment?",FALSE));
$id = $mysidia->input->post("submit");
$form = new Form("title","","post");
$form->add(new Button("Yes","submit2",$id));
$document->add($form);

}

if($mysidia->input->post("submit2")){
$id = $mysidia->input->post("submit2");
//echo $id;
$mysidia->db->delete("newscomments","id = {$id}");
$document->add(new Comment("<b>Comment deleted successfully.</b>",FALSE));
$news = $this->getField("news2");
$newsComments = $news->getComments();
}

while($newsID = $newsComments->fetchColumn()){
try{
$newsComment = new NewsComments($newsID);
$cells = new LinkedList;
$cells->add(new TCell($newsComment->getUserObject()->getUsername()));
$cells->add(new TCell($newsComment->getDate()));
$cells->add(new TCell($newsComment->getContent()));
$cells->add(new TCell(new Link("admincp/news/editcomment/{$newsComment->getID()}","Edit")));
$form = new Form("form","","post");
$form->add(new Button("Delete","submit",$newsID));
$cells->add(new TCell($form));
$pagesTable->buildRow($cells);
}
catch(NoPermissionException $e){

}

}

$document->add($pagesTable);
}

public function editcomment(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("editing comments");
$newsComment = $this->getField("newscomments");
$editor = $this->getField("editor")->get();

if($mysidia->input->post("submit")){
$newsComment->setContent($mysidia->input->post("commentcontent"));
$document->add(new Comment("<b>Edited news comment successfully. Text displayed is the old one.<br></b>",FALSE));
$newsComment = $this->getField("newscomments");
$editor = $this->getField("editor")->get();
}

$document->add(new Comment("Author: {$newsComment->getUserObject()->getUsername()} / Date: {$newsComment->getDate()}",FALSE));
$form = new Form("form","","post");

$form->add(new Comment($editor,FALSE));
$form->add(new Button("Submit","submit","submit"));
$document->add($form);
}

public function edit(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("Edit");


$news = $this->getField("news");
if($mysidia->input->post("submit")){

($mysidia->input->post("allowcomments"))?$allow = "yes":$allow = "no";

$news->editTitle($mysidia->input->post("newstitle"));
$news->editContent($this->format($mysidia->input->post("pagecontent")));
$news->changeAllowComment($allow);

if($mysidia->input->post("submit") == "submitDraft"){
$news->saveDraft();
}

else{
$news->post();
}
$document->add(new Comment("<b>Successfully changed news.</b>"));
}

$editor = $this->getField("editor")->get()->editor("pagecontent", $this->format($news->getContent()));
$form = new Form("title","","post");
$form->add(new Comment("<b>Date</b>:{$news->getDate()} and <b>Author</b>: {$news->getUserObject()->getUsername()} and <b>Published</b>: {$news->getPosted()}"));
$form->add(new Comment("<b>Title</b>:"));
$form->add(new TextField("newstitle",$news->getTitle()));
$form->add(new Comment("<b>Contents</b>:"));
$form->add(new Comment($editor));
$comments = new CheckBox("Allow comments on this news", "allowcomments", 1, "array");
if($news->getAllowComment() == "yes")
$comments->setChecked("allowcomments");
$comments2 = new CheckBox("Send message to all users notifying about the existence of an update", "allowmessage", 2, "array");
$form->add($comments);
$form->add($comments2);
$form->add(new Button("Save as draft","submit","submitDraft"));
$form->add(new Button("Publish","submit","submitPublish"));
$document->add($form);


}

public function create(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("Create");

if($mysidia->input->post("submit")){
$todayDate = new DateTime;
$date = $todayDate->format('Y-m-d H:i:s');

($mysidia->input->post("allowcomments"))?$allow = "yes":$allow = "no";


if($mysidia->input->post("submit") == "submitDraft"){

$mysidia->db->insert("news",array("title" => $mysidia->input->post("newstitle"), "content" => $this->format($mysidia->input->post("pagecontent")), "user" => $mysidia->user->uid, "date" => $date, "posted" => "no","allowcomment" => $allow));
}

else{

$mysidia->db->insert("news",array("title" => $mysidia->input->post("newstitle"), "content" => $this->format($mysidia->input->post("pagecontent")), "user" => $mysidia->user->uid, "date" => $date, "posted" => "yes","allowcomment" => $allow));

if($mysidia->input->post("allowmessage")){
//$mysidia->db->insert("");
}
}
$document->add(new Comment("<b>Successfully changed news. Fill this page again to create a new post. Click <a href='/news' target='_blank'>here</a> to see the news page.</b>"));
}
$todayDate = new DateTime;
$date = $todayDate->format('Y-m-d');
$editor = $this->getField("editor")->get();
$form = new Form("title","","post");
$form->add(new Comment("<b>Date</b>:{$date} and <b>Author</b>: {$mysidia->user->username} and <b>Published</b>: No"));
$form->add(new Comment("<b>Title</b>:"));
$form->add(new TextField("newstitle",""));
$form->add(new Comment("<b>Contents</b>:"));
$form->add(new Comment($editor));
$comments = new CheckBox("Allow comments on this news", "allowcomments", 1, "array");
$comments2 = new CheckBox("Send message to all users notifying about the existence of an update", "allowmessage", 2, "array");
$form->add($comments);
$form->add($comments2);
$form->add(new Button("Save as draft","submit","submitDraft"));
$form->add(new Button("Publish","submit","submitPublish"));
$document->add($form);
}

private function format($text){
$text = html_entity_decode($text);
$text = stripslashes($text);
$text = str_replace("rn","",$text);
return $text;
}
}
?>

And so you can add the admincp/news link to your site, go to the file class_adminsidebar.php in the folder classes and find this:


$components->add(new Division(new Comment("Images", FALSE)));
$image = new Division;
$image->add(new Link("admincp/image/upload", "Upload Images"));
$image->add(new Link("admincp/image/delete", "Erase Images"));
$image->add(new Link("admincp/image/settings", "Adoptable Signature Image/GD Settings"));
$components->add($image);

Add this after that piece of code:

$components->add(new Division(new Comment("News", FALSE)));
$news = new Division;
$news->add(new Link("admincp/news", "Manage News and Comments"));
$news->add(new Link("admincp/news/create", "Create News"));
$components->add($news);

Part 5: The CSS
If you just added started adding news you will see that the news won't display like what the pictures show. I modified the CSS in order to look like that.
If you are using the main theme, go to templates/main/media/style-city.css and add this at the bottom:

.news fieldset{
color:black;
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAA p4XiDAAAAUVBMVEWFhYWDg4N3d3dtbW17e3t1dXWBgYGHh4d5e Xlzc3OLi4ubm5uVlZWPj4+NjY19fX2JiYl/f39ra2uRkZGZmZlpaWmXl5dvb29xcXGTk5NnZ2c8TV1mAAAAG3 RSTlNAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEAvEOwtAAAF VklEQVR4XpWWB67c2BUFb3g557T/hRo9/WUMZHlgr4Bg8Z4qQgQJlHI4A8SzFVrapvmTF9O7dmYRFZ60YiB hJRCgh1FYhiLAmdvX0CzTOpNE77ME0Zty/nWWzchDtiqrmQDeuv3powQ5ta2eN0FY0InkqDD73lT9c9lEzwU NqgFHs9VQce3TVClFCQrSTfOiYkVJQBmpbq2L6iZavPnAPcoU0 dSw0SUTqz/GtrGuXfbyyBniKykOWQWGqwwMA7QiYAxi+IlPdqo+hYHnUt5ZP fnsHJyNiDtnpJyayNBkF6cWoYGAMY92U2hXHF/C1M8uP/ZtYdiuj26UdAdQQSXQErwSOMzt/XWRWAz5GuSBIkwG1H3FabJ2OsUOUhGC6tK4EMtJO0ttC6IBD3k M0ve0tJwMdSfjZo+EEISaeTr9P3wYrGjXqyC1krcKdhMpxEnt5 JetoulscpyzhXN5FRpuPHvbeQaKxFAEB6EN+cYN6xD7RYGpXpN ndMmZgM5Dcs3YSNFDHUo2LGfZuukSWyUYirJAdYbF3MfqEKmjM +I2EfhA94iG3L7uKrR+GdWD73ydlIB+6hgref1QTlmgmbM3/LeX5GI1Ux1RWpgxpLuZ2+I+IjzZ8wqE4nilvQdkUdfhzI5QDWy +kw5Wgg2pGpeEVeCCA7b85BO3F9DzxB3cdqvBzWcmzbyMiqhzu YqtHRVG2y4x+KOlnyqla8AoWWpuBoYRxzXrfKuILl6SfiWCbjx oZJUaCBj1CjH7GIaDbc9kqBY3W/Rgjda1iqQcOJu2WW+76pZC9QG7M00dffe9hNnseupFL53r8F7Y HSwJWUKP2q+k7RdsxyOB11n0xtOvnW4irMMFNV4H0uqwS5Exsm P9AxbDTc9JwgneAT5vTiUSm1E7BSflSt3bfa1tv8Di3R8n3Af7 MNWzs49hmauE2wP+ttrq+AsWpFG2awvsuOqbipWHgtuvuaAE+A 1Z/7gC9hesnr+7wqCwG8c5yAg3AL1fm8T9AZtp/bbJGwl1pNrE7RuOX7PeMRUERVaPpEs+yqeoSmuOlokqw49pgom jLeh7icHNlG19yjs6XXOMedYm5xH2YxpV2tc0Ro2jJfxC50Apu xGob7lMsxfTbeUv07TyYxpeLucEH1gNd4IKH2LAg5TdVhlCafZ vpskfncCfx8pOhJzd76bJWeYFnFciwcYfubRc12Ip/ppIhA1/mSZ/RxjFDrJC5xifFjJpY2Xl5zXdguFqYyTR1zSp1Y9p+tktDYYSNf lcxI0iyO4TPBdlRcpeqjK/piF5bklq77VSEaA+z8qmJTFzIWiitbnzR794USKBUaT0NTEsVj ZqLaFVqJoPN9ODG70IPbfBHKK+/q/AWR0tJzYHRULOa4MP+W/HfGadZUbfw177G7j/OGbIs8TahLyynl4X4RinF793Oz+BU0saXtUHrVBFT/DnA3ctNPoGbs4hRIjTok8i+algT1lTHi4SxFvONKNrgQFAq2/gFnWMXgwffgYMJpiKYkmW3tTg3ZQ9Jq+f8XN+A5eeUKHWvJWJ2 sgJ1Sop+wwhqFVijqWaJhwtD8MNlSBeWNNWTa5Z5kPZw5+LbVT 99wqTdx29lMUH4OIG/D86ruKEauBjvH5xy6um/Sfj7ei6UUVk4AIl3MyD4MSSTOFgSwsH/QJWaQ5as7ZcmgBZkzjjU1UrQ74ci1gWBCSGHtuV1H2mhSnO3Wp/3fEV5a+4wz//6qy8JxjZsmxxy5+4w9CDNJY09T072iKG0EnOS0arEYgXqYnXcY HwjTtUNAcMelOd4xpkoqiTYICWFq0JSiPfPDQdnt+4/wuqcXY47QILbgAAAABJRU5ErkJggg==);
border-radius:5px;
border:white;
background-color: white;
/*border:2px dotted black;*/
border-bottom: 3px solid brown;

}

.news .content .authorimg{
float:left;
border: 1px dotted black;
padding:2px;
margin-right:10px;
margin-bottom:4px;
}

.news fieldset .title:before{
content:'>>> ';
font-size:11px;
}

.news{
color:brown;
}
.news fieldset .content{
text-align:justify;
color:black;
}

.news .date {
font-size:10px;
font-weight: bold;
color:brown;
}

.news .author a{
color:orange;
}

.news .author a:hover{
color:brown;
}

.news .title {
font-size:25px;
font-weight:bold;
color:orange;

}

.news .author:before {
content: ' | ';
}
.news .author {
color:brown;
font-size:10px;
}

.news .comment{
font-size:10px;
}

.news .comment:before{
content: ' | ';
}

.pages{
color:brown;
}
.page{
color:white;
background-color:brown;
border-radius:5px;
border:2px solid brown;
}
.page:hover{
color:orange;
background-color:white;
border:0px;
}

.cdate{
font-size:10px;
font-weight: bold;
color:brown;
}

.cauthor{
color:brown;
font-size:10px;
}
.ccontent{
font-size:10px;
text-align:justify;
color:black;
}

.ccontent img{
float:left;
border: 1px dotted black;
padding:2px;
margin-right:10px;
margin-bottom:4px;
}

If you aren't using the main theme, Add that to the css of whatever theme you are using. Right click the page to see the HTML and check what each class does what.


----------------

Please warn me of any bugs you find. I tested it and it should be working properly, so please warn me if you find something that wasn't supposed to happen.

Hall of Famer
02-14-2014, 03:17 PM
Nice work, I am sure it took you quite a while to get this done and it must've been a valuable experience. It seems that you are getting a good understanding of the OOP and MVC system, which is nice to know. I hope users like it. ^^

I was wondering though, can you possibly provide a .rar or .zip file for users to download the files and uploads easily? This is likely to work for most sites since I see most of the changes are in new files.

Abronsyth
02-14-2014, 03:38 PM
Brilliant! Once I get my file transfers working again (glitches are killing me) I'll most certainly be trying this out! I've been dying for a news system, haha <3 ((Though I still plan to fix up my own...just hard to juggle learning code with everything else that's going on...))

IntoRain
02-14-2014, 03:47 PM
Nice work, I am sure it took you quite a while to get this done and it must've been a valuable experience. It seems that you are getting a good understanding of the OOP and MVC system, which is nice to know. I hope users like it. ^^

I was wondering though, can you possibly provide a .rar or .zip file for users to download the files and uploads easily? This is likely to work for most sites since I see most of the changes are in new files.

Thank you! I had contact with OOP before in other language, but it's the first time using MVC, although it makes sense xD Getting the pages in jQuery to work was actually what took me longer to get (and I found two bugs today, so I'm not really confident about it xD ). I tried to implement this one (http://flaviusmatis.github.io/simplePagination.js/) but for some reason it wasn't working, so I made my own (it's simple and actually just hides the news that aren't supposed to show on a certain page lol)

Sure thing! I will add them to the first post! Actually makes things easier xD

Brilliant! Once I get my file transfers working again (glitches are killing me) I'll most certainly be trying this out! I've been dying for a news system, haha <3 ((Though I still plan to fix up my own...just hard to juggle learning code with everything else that's going on...))

Thank you! Hopefully this will be helpful for you!

Hall of Famer
02-14-2014, 03:53 PM
I understand what you mean. Yeah Mysidia is not quite friendly with JQuery and javascript libraries at this moment, but it is expected to change in future. I am glad to know that you figured it out in the end, it could definitely take a while. Kyttias also told me that getting JQuery to work with Mysidia was painful. XD

IntoRain
02-14-2014, 04:04 PM
I understand what you mean. Yeah Mysidia is not quite friendly with JQuery and javascript libraries at this moment, but it is expected to change in future. I am glad to know that you figured it out in the end, it could definitely take a while. Kyttias also told me that getting JQuery to work with Mysidia was painful. XD

It seems that adding .js files with jQuery to the header/template makes it not work properly for some reason, it took a while to figure out why it wasn't making a simple popup when the only thing I did was alert('hey') xD
A good thing about javascript in mysidia is that you can magically send php variables to the javascript since the script is inside a comment, without the need to query the database with ajax. So that's a good side! xD

tahbikat
02-14-2014, 09:48 PM
This is WONDERFUL! I'm going to have to add this to my site soon! ^^ Awesome!

IntoRain
02-14-2014, 10:51 PM
I'm Glad it will be useful *hopefully* for your site!

Vaporman87
02-23-2014, 12:58 AM
Got this up and running on my site. Thanks a bunch for this IntoRain!!!

IntoRain
02-23-2014, 09:14 AM
You're welcome! Glad it worked for you! ^^ If you detect any bug, don't hesitate to tell me!

Vaporman87
02-24-2014, 09:37 AM
The only thing I noticed is that if you have your site in a subfolder, you need to go in and change the following code in the /view/newsview.php file:

$newsObj = new News($news);
$index++;
$newsField = new Fieldset("news$index");
$comments = $newsObj->getCommentNumber();
$newsField->add(new Comment("<span class='date'>Date: {$newsObj->getDate()}</span><br>",FALSE));
$newsField->add(new Comment("<span class='title'>{$newsObj->getTitle()}</span>",FALSE));
$newsField->add(new Comment("<span class='author'>by <a href='/profile/view/{$newsObj->getUserObject()->getUsername()}' target='_blank'>{$newsObj->getUserObject()->getUsername()}</a></span>",FALSE));
$newsField->add(new Comment("<span class='comment'><a href='/news/view/{$newsObj->getID()}'>Comments({$comments})</a></span><br>",FALSE));
$newsField->add(new Comment("<span class='content'><img class='authorimg' src='{$newsObj->getUserObject()->getprofile()->getavatar()}'>{$newsObj->getContent()}</span>",FALSE));

I added my subfolder name, "DigiChars", before the " /news/view/ " and " /profile/view/ " text.

IntoRain
02-25-2014, 08:55 AM
Thank you! I will add a note to the first post!

Missy Master
02-26-2014, 08:36 PM
This looks really good! I cant wait to try this out --- thanks for sharing this with us! :)

IntoRain
03-03-2014, 06:55 PM
This looks really good! I cant wait to try this out --- thanks for sharing this with us! :)

Thank you for the support! ^^

Kesstryl
03-05-2014, 01:21 AM
Nice mod, will definitely use this once I start working on my site. Right now I've been diggin g deep into learning MVC, OOP, and PDO before I even touch Mysidia.

Abronsyth
03-07-2014, 06:01 PM
Just created and added everything and it is functioning perfectly! I have to fix up the formatting a little bit so it works more neatly with the theme, but it's awesome so far!

How do you think one should go about making it so that a news alert appears at the top of the page until the member visits the news page? So each time a new news post is added members are alerted when they logon?

IntoRain
03-09-2014, 08:16 PM
Nice mod, will definitely use this once I start working on my site. Right now I've been diggin g deep into learning MVC, OOP, and PDO before I even touch Mysidia.

Thank you! Hope it works well for you! ^^ OOP is one of those concepts that will make so much sense once it clicks xD

Just created and added everything and it is functioning perfectly! I have to fix up the formatting a little bit so it works more neatly with the theme, but it's awesome so far!

How do you think one should go about making it so that a news alert appears at the top of the page until the member visits the news page? So each time a new news post is added members are alerted when they logon?

Yay glad it worked for you! ^^ THank you for the input!
I was thinking of sending a new message to users to alert them of a new news, but I kinda got lazy and didn't do it lol
I guess it would work exactly like the messages system that alerts users when they get a new message. Maybe another table that contains all users and a field that says if they have been to the news page ever since a new news was posted. So when posting a news, all fields would reset to "unread" for all users and while it was unread, a message would appear somewhere in the site

Abronsyth
09-24-2014, 06:26 PM
Okay, I'm having this error:
CREATE TABLE `newscomments` (

`id` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`newsID` INT( 5 ) NOT NULL DEFAULT 'None',
`userID` INT( 5 ) NOT NULL DEFAULT 'None',
`comment` VARCHAR( 300 ) NULL DEFAULT NULL ,
`date` VARCHAR( 30 ) NULL DEFAULT NULL
) ENGINE = MYISAM
MySQL said: Documentation

#1067 - Invalid default value for 'newsID'

Any ideas?

IntoRain
09-24-2014, 07:10 PM
Okay, I'm having this error:
CREATE TABLE `newscomments` (

`id` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`newsID` INT( 5 ) NOT NULL DEFAULT 'None',
`userID` INT( 5 ) NOT NULL DEFAULT 'None',
`comment` VARCHAR( 300 ) NULL DEFAULT NULL ,
`date` VARCHAR( 30 ) NULL DEFAULT NULL
) ENGINE = MYISAM
MySQL said: Documentation

#1067 - Invalid default value for 'newsID'

Any ideas?

Did you write "None" instead of selecting 'None' from the list? If it's not that, you can try running it directly and removing the default part:

CREATE TABLE `[your_prefix_here]_newscomments` (

`id` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`newsID` INT( 5 ) NOT NULL,
`userID` INT( 5 ) NOT NULL,
`comment` VARCHAR( 300 ) NULL DEFAULT NULL ,
`date` VARCHAR( 30 ) NULL DEFAULT NULL
) ENGINE = MYISAM

This is by clicking on the "SQL" tab. Like here: http://i.imgur.com/VGRaF82.png

Abronsyth
09-25-2014, 04:37 AM
The phpMyAdmin that my host is using seems to be a bit dated, so it doesn't actually have a drop-down for most of the parts. I'll go through and run it directly to see if that'll work.

Thank you :)

IntoRain
09-25-2014, 08:20 AM
Ah, I see. I think the error is because the value is an integer and "None" was a string. Since the values can't be null, they don't need a default value, so I think it won't hurt to remove it
I hope it works! :)

edit: Added a step I forgot to the tutorial...

parayna
10-04-2014, 03:20 PM
Heya ^_^ I am using this Mod (everything works great!) but do you know how I would change the time zone? I am in the UK, see, and it is set in a time zone 5 hours back (so like at 9 my time, it says it was posted at 4, for example)

Thank you ^_^ (I just want it UK time because I am from the UK XD) Also, if there is a way for it to automatically detect a user's time zone and change the times for them that would be great as well! (But I know little about coding so I have no idea how that would be possible...)

IntoRain
10-04-2014, 04:10 PM
Heya ^_^ I am using this Mod (everything works great!) but do you know how I would change the time zone? I am in the UK, see, and it is set in a time zone 5 hours back (so like at 9 my time, it says it was posted at 4, for example)

Thank you ^_^ (I just want it UK time because I am from the UK XD) Also, if there is a way for it to automatically detect a user's time zone and change the times for them that would be great as well! (But I know little about coding so I have no idea how that would be possible...)

Glad it's working for you!

You can set the DateTime thingy to your timezone, but I don't think it's possible to set it to the user's timezone. Perhaps with javascript, but I'm not really sure how

Check the file newsview.php inside admincp/view, and search for this part:


public function create(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("Create");

if($mysidia->input->post("submit")){
$todayDate = new DateTime;

//add the following line:
$todayDate->setTimezone(new DateTimeZone('Europe/London'));

$date = $todayDate->format('Y-m-d H:i:s');
//rest of the code here


I assumed London, but here's the list of available timezones you can use: http://php.net/manual/en/timezones.php

I just used it for my country and it's 1 hour behind lol

parayna
10-04-2014, 06:16 PM
OK! Thank you! ^_^ (And yeah, mine is the London one, good guess :P)

EDIT: Yay! It worked! Thanks! :D

parayna
10-07-2014, 05:36 PM
Hi again! Sorry for the double post but I seem to have run into something... for some reason the CSS file part won't let me change it. And it is only working for one of my themes...

There aren't any errors popping up or anything, just the CSS of the news page doesn't work on my second theme (it's set to the default, blank one). I have put it into the same file I did to put it into my first theme, but it won't work.

I tried to change it as well (to better suit my first theme) but the images/colours won't change even when I remove the image link for the grey body image, and replace it with my own. Neither will the colours for the borders change when I add a different colour in... do you have any ideas as to what the problem could be? It's kinda confusing me... XD

IntoRain
10-07-2014, 06:00 PM
Hi again! Sorry for the double post but I seem to have run into something... for some reason the CSS file part won't let me change it. And it is only working for one of my themes...

There aren't any errors popping up or anything, just the CSS of the news page doesn't work on my second theme (it's set to the default, blank one). I have put it into the same file I did to put it into my first theme, but it won't work.

I tried to change it as well (to better suit my first theme) but the images/colours won't change even when I remove the image link for the grey body image, and replace it with my own. Neither will the colours for the borders change when I add a different colour in... do you have any ideas as to what the problem could be? It's kinda confusing me... XD

You might be editing the wrong .css file? The templates/main/media/style-city.css file is just for the main theme, other themes might be in different folders like templates/(other_theme)/.../file.css. Inspect your site's source code (right click > inspect/view code/or similar) to check which .css files it's using with that theme. Might be that xD

parayna
10-07-2014, 06:08 PM
I made the themes myself and each theme uses a different style-city.css XD Unless you're not supposed to do that..? I just had trouble getting the bleedin' thing to work so I used the same name XD (just added different pictures for like the background and changed the colours in each one)

EDIT: Grr... got it working XD Finally, I managed to make the theme work with a differently named style-city.css. I changed it to style-red.css and refreshed the page and all of a sudden it decided to work! XD Thanks though ^_^

parayna
12-08-2014, 10:28 AM
Hello, I know this hasn't been commented on for a while but do you know how to get the 'Send message to all users notifying about the existence of an update' button working? I think I recall you saying it doesn't work yet but I am thinking of trying to get it working..

Would it be possible to have it so that when that box is ticked it automatically updates the 'messages' database table? (Maybe not an email, just a PM on your site) As in, when you tick it every user on the site gets a PM from 'SYSTEM' or even just the admin...

Would that be possible? Sorry for bugging XD

~Parayna

IntoRain
12-08-2014, 01:45 PM
Hello, I know this hasn't been commented on for a while but do you know how to get the 'Send message to all users notifying about the existence of an update' button working? I think I recall you saying it doesn't work yet but I am thinking of trying to get it working..

Would it be possible to have it so that when that box is ticked it automatically updates the 'messages' database table? (Maybe not an email, just a PM on your site) As in, when you tick it every user on the site gets a PM from 'SYSTEM' or even just the admin...

Would that be possible? Sorry for bugging XD

~Parayna

Sorry, I didn't get back to this mod because my host started having problems and the loading times were too crazy to get anything done.

My idea was to send a PM to everyone in the site. The condition to send PM's is already there:

newview.php

else{

$mysidia->db->insert("news",array("title" => $mysidia->input->post("newstitle"), "content" => $this->format($mysidia->input->post("pagecontent")), "user" => $mysidia->user->uid, "date" => $date, "posted" => "yes","allowcomment" => $allow));

if($mysidia->input->post("allowmessage")){
//$mysidia->db->insert("");
}
}


Next, inside the if, you'd need to retrieve all user ID's from the users table and use a loop to add the message to the messages table, one for each user (you might need the username instead of the userid, I don't remember which one the messages table uses x.x). This was my first idea, I wanted to do something prettier but I didn't come up with anything else lol

parayna
12-09-2014, 12:23 PM
Thanks for replying ^_^ I might have a little go when I have more time XD

Thanks~

parayna
12-11-2014, 08:36 AM
Well, I tried and failed :cfrown: I think your way would work but I can't make sense of putting it together... I have no idea what to put or where. I understand that you need to edit the database but I have no idea what to write into the code to update each field (I am a very novice coder....) I have been trying for a while now but I can't seem to get it right.. :mii: I have even been looking at other files from the script to see if there is similar coding that I could use and there probably is but I can't make sense from it.. ^_^''

...could you please help me when you have some spare moments? Thank you... >.<

~Parayna

IntoRain
12-11-2014, 06:32 PM
Well, I tried and failed :cfrown: I think your way would work but I can't make sense of putting it together... I have no idea what to put or where. I understand that you need to edit the database but I have no idea what to write into the code to update each field (I am a very novice coder....) I have been trying for a while now but I can't seem to get it right.. :mii: I have even been looking at other files from the script to see if there is similar coding that I could use and there probably is but I can't make sense from it.. ^_^''

...could you please help me when you have some spare moments? Thank you... >.<

~Parayna

I will post it tomorrow asap! I'm sorry, I was going to code it after you answered, but it's the last week of the semester and I have 4 projects to deliver in a few days xD

parayna
12-12-2014, 11:59 AM
Thank you! It's fine, to be honest I can't wait until I have learnt coding more and can code things myself XD I know it's a matter of time but I really want to be able to do things like this myself instead of relying on other people who may or may not be busy >.< But thanks all the same! XD

~Parayna

parayna
12-16-2014, 09:57 PM
...bump... ^_^

IntoRain
12-18-2014, 06:18 PM
Sorry for the late

Adding a "send message to all users" option:


Go to your database, and select your news table.
At the top, if you are using phpMyAdmin, select to edit the table's structure.
At the bottom you will see an "Add (1) columns..." click execute
Create a new columns like this:

Name: allowmessage
Type: varchar
Size: 3
Predefined: As defined -> "no"
Select "Null" checkbox

Go to your class_news.php file and change it to this: (new stuff is commented with "NEW!")

<?php

use Resource\Native\Object;
use Resource\Native\Arrays;

class News extends Object {


private $id;
private $user;
private $title;
private $content;
private $date;
private $posted;
private $comments;
private $allowcomment;
private $allowmessage;//NEW!

public function __construct($id){
$mysidia = Registry::get("mysidia");
$whereClause = "id = '{$id}'";
$row = $mysidia->db->select("news",array(),$whereClause)->fetchObject();
if(!is_object($row)) throw new NoPermissionException("News doesn't exist");
foreach($row as $key => $val){
$this->$key = $val;
}
$this->comments = $mysidia->db->select("newscomments",array("id"),"newsID = {$this->id} ORDER BY date,id");
}

public function getID(){
return $this->id;
}

public function getUser(){
return $this->user;
}

public function getUserObject(){
$mysidia = Registry::get("mysidia");
$user = new Member($this->user);
return $user;
}
public function getTitle(){
return $this->title;
}

public function getContent(){
return $this->content;
}

public function getDate(){
return $this->date;
}

public function getPosted(){
return $this->posted;
}

public function getAllowComment(){
return $this->allowcomment;
}

//NEW!
public function getAllowMessage(){
return $this->allowmessage;
}

public function changeAllowComment($allow){
$mysidia = Registry::get("mysidia");
if($this->allowcomment != $allow){
$this->allowcomment = $allow;
$mysidia->db->update("news",array("allowcomment" => $this->allowcomment),"id = {$this->id}");
}

}

//NEW!
public function changeAllowMessage($allow){
$mysidia = Registry::get("mysidia");
if($this->allowmessage != $allow){
$this->allowmessage = $allow;
$mysidia->db->update("news",array("allowmessage" => $this->allowmessage),"id = {$this->id}");
}

}

public function addComment($content,$date,$user){
$mysidia = Registry::get("mysidia");
$mysidia->db->insert("newscomments",array("comment" => $this->format($content), "date" => $date, "userID" => $user, "newsID" => $this->id));
$this->comments = $mysidia->db->select("newscomments",array("id"),"newsID = {$this->id} ORDER BY date,id");
}

private function format($text){
$text = html_entity_decode($text);
$text = stripslashes($text);
$text = str_replace("rn","",$text);
return $text;
}

public function saveDraft(){
$mysidia = Registry::get("mysidia");
$todayDate = $this->todayDate();
if($this->date != $todayDate) $this->newDate($todayDate);
$this->posted = "no";
$mysidia->db->update("news",array("posted" => $this->posted),"id = {$this->id}");
}

public function post(){
$mysidia = Registry::get("mysidia");
$todayDate = $this->todayDate();
if($this->date != $todayDate) $this->newDate($todayDate);
$this->posted = "yes";
$mysidia->db->update("news",array("posted" => $this->posted),"id = {$this->id}");
//NEW!
if($this->allowmessage == "yes")
$this->sendToAllUsers($todayDate);
}

//NEW!
public function sendToAllUsers($dateToday) {
$mysidia = Registry::get("mysidia");
$allusers = $mysidia->db->select("users", array("username"), "");
$messageTitle = "Update";
$messagetext = "A new news was posted on the site! Click <a href='/news'>here</a> to view!<br>";

while($user = $allusers->fetchColumn()){
$mysidia->db->insert("messages", array("fromuser" => "SYSTEM", "touser" => $user, "status" => "unread", "datesent" => $dateToday, "messagetitle" => $messageTitle, "messagetext" => $messagetext), "");
}
}

public function editContent($content){
$mysidia = Registry::get("mysidia");
$this->content = $content;
$mysidia->db->update("news",array("content" => $this->content),"id = {$this->id}");
}

public function editTitle($title){
$mysidia = Registry::get("mysidia");
$this->title = $title;
$mysidia->db->update("news",array("title" => $this->title),"id = {$this->id}");
}

public function todayDate(){
$dateTime = new DateTime;
$date = $dateTime->format('Y-m-d H:i:s');
return $date;
}
public function newDate($date){
$mysidia = Registry::get("mysidia");
$this->date = $date;
$mysidia->db->update("news",array("date" => $this->date),"id = {$this->id}");
}

public function getCommentNumber(){
$count = $this->comments->rowCount();
return $count;
}

public function getComments(){
return $this->comments;
}

}

?>

Go to your newsview.php file inside the admincp folder and change it to this: (new stuff is commented with "NEW!")

<?php

use Resource\Native\String;
use Resource\Collection\LinkedList;
use Resource\Collection\LinkedHashMap;

class ACPNewsView extends View{

private $editor;

public function index(){
//parent::index();
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("Manage News And Comments");

$pagesTable = new TableBuilder("news");
$pagesTable->setAlign(new Align("center", "middle"));

$pagesTable->buildHeaders("News Title", "Author", "Date", "Edit", "Publish/Save", "Delete", "View Comments", "View News");

$allnews = $this->getField("news")->get();

if($mysidia->input->post("submit")){
$id = $mysidia->input->post("submit");
$newsObj = new News($id);
$newsObj->saveDraft();
$document->add(new Comment("<b>Successfully saved news as draft</b>",TRUE));
}

if($mysidia->input->post("submit1")){
$id = $mysidia->input->post("submit1");
$newsObj = new News($id);
$newsObj->post();
$document->add(new Comment("<b>Successfully added and published news.</b>",TRUE));
}

if($mysidia->input->post("submit2")){
$id = $mysidia->input->post("submit2");
$newsObj = new News($id);
$document->add(new Comment("Are you sure you wish to delete this news?",TRUE));
$form = new Form("title","","post");
$form->add(new Button("Yes","submit5",$id));
$document->add($form);

}
if($mysidia->input->post("submit5")){
$id = $mysidia->input->post("submit5");
$mysidia->db->delete("news","id = {$id}");
$document->add(new Comment("Successfully deleted news",TRUE));
$allnews = $mysidia->db->select("news",array("id"),"");
}

while($news = $allnews->fetchColumn()){
$newsObj = new News($news);
$cells = new LinkedList;
($newsObj->getPosted() == "yes")? $draft = "":$draft = "(draft)";
$title = "{$newsObj->getTitle()} {$draft}";
$cells->add(new TCell($title));
$cells->add(new TCell($newsObj->getUserObject()->getUsername()));
$cells->add(new TCell($newsObj->getDate()));
$cells->add(new TCell(new Link("admincp/news/edit/{$news}","Edit")));

$form = new Form("title","","post");
$form->add(new Button("Save As Draft","submit",$news));
$form2 = new Form("title","","post");
$form2->add(new Button("Publish","submit1",$news));
$form3 = new Form("title","","post");
$form3->add(new Button("Delete","submit2",$news));

($newsObj->getPosted() == "yes")? $cells->add(new TCell($form)) : $cells->add(new TCell($form2));
$cells->add(new TCell($form3));
$cells->add(new TCell(new Link("admincp/news/viewcomments/{$news}","View Comments")));
$cells->add(new TCell(new Link("news/view/{$news}","View News On Site")));
$pagesTable->buildRow($cells);
}

$document->add($pagesTable);
$document->add(new Comment("<a href='/admincp/news/create'>Create</a>",TRUE));

}

public function viewcomments(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("editing comments");
$news = $this->getField("news");

$newsComments = $news->getComments();


$pagesTable = new TableBuilder("news");
$pagesTable->setAlign(new Align("center", "middle"));

$pagesTable->buildHeaders("Author", "Date", "Content", "Edit", "Delete");

if($mysidia->input->post("submit")){
$document->add(new Comment("Are you sure you wish to delete this comment?",FALSE));
$id = $mysidia->input->post("submit");
$form = new Form("title","","post");
$form->add(new Button("Yes","submit2",$id));
$document->add($form);

}

if($mysidia->input->post("submit2")){
$id = $mysidia->input->post("submit2");
//echo $id;
$mysidia->db->delete("newscomments","id = {$id}");
$document->add(new Comment("<b>Comment deleted successfully.</b>",FALSE));
$news = $this->getField("news2");
$newsComments = $news->getComments();
}

while($newsID = $newsComments->fetchColumn()){
try{
$newsComment = new NewsComments($newsID);
$cells = new LinkedList;
$cells->add(new TCell($newsComment->getUserObject()->getUsername()));
$cells->add(new TCell($newsComment->getDate()));
$cells->add(new TCell($newsComment->getContent()));
$cells->add(new TCell(new Link("admincp/news/editcomment/{$newsComment->getID()}","Edit")));
$form = new Form("form","","post");
$form->add(new Button("Delete","submit",$newsID));
$cells->add(new TCell($form));
$pagesTable->buildRow($cells);
}
catch(NoPermissionException $e){

}

}

$document->add($pagesTable);
}

public function editcomment(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("editing comments");
$newsComment = $this->getField("newscomments");
$editor = $this->getField("editor")->get();

if($mysidia->input->post("submit")){
$newsComment->setContent($mysidia->input->post("commentcontent"));
$document->add(new Comment("<b>Edited news comment successfully. Text displayed is the old one.<br></b>",FALSE));
$newsComment = $this->getField("newscomments");
$editor = $this->getField("editor")->get();
}

$document->add(new Comment("Author: {$newsComment->getUserObject()->getUsername()} / Date: {$newsComment->getDate()}",FALSE));
$form = new Form("form","","post");

$form->add(new Comment($editor,FALSE));
$form->add(new Button("Submit","submit","submit"));
$document->add($form);
}

public function edit(){


//include_once("../inc/ckeditor/ckeditor.php");
$mysidia = Registry::get("mysidia");
//$this->editor = new CKEditor;
//$this->editor->basePath = '../../../inc/ckeditor/';
$document = $this->document;
$document->setTitle("Edit");


$news = $this->getField("news");

if($mysidia->input->post("submit")){
/*if(!$mysidia->input->post("newstitle")) throw new BlankFieldException("No title");
if(!$mysidia->input->post("newscontent")) throw new BlanKFieldException("No content");*/

($mysidia->input->post("allowcomments"))?$allow = "yes":$allow = "no";
//NEW!
($mysidia->input->post("allowmessage"))?$allowM = "yes":$allowM = "no";

$news->editTitle($mysidia->input->post("newstitle"));
$news->editContent($this->format($mysidia->input->post("pagecontent")));
$news->changeAllowComment($allow);
//NEW!
$news->changeAllowMessage($allowM);

if($mysidia->input->post("submit") == "submitDraft"){
$news->saveDraft();
}

else{
$news->post();
}
$document->add(new Comment("<b>Successfully changed news.</b>"));
}

$editor = $this->getField("editor")->get()->editor("pagecontent", $this->format($news->getContent()));
$form = new Form("title","","post");
$form->add(new Comment("<b>Date</b>:{$news->getDate()} and <b>Author</b>: {$news->getUserObject()->getUsername()} and <b>Published</b>: {$news->getPosted()}"));
$form->add(new Comment("<b>Title</b>:"));
$form->add(new TextField("newstitle",$news->getTitle()));
$form->add(new Comment("<b>Contents</b>:"));
$form->add(new Comment($editor));
$comments = new CheckBox("Allow comments on this news", "allowcomments", 1, "array");
if($news->getAllowComment() == "yes")
$comments->setChecked("allowcomments");
$comments2 = new CheckBox("Send message to all users notifying about the existence of an update", "allowmessage", 2, "array");
$form->add($comments);
$form->add($comments2);
$form->add(new Button("Save as draft","submit","submitDraft"));
$form->add(new Button("Publish","submit","submitPublish"));
$document->add($form);

//echo $mysidia->user->uid;

}

public function create(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("Create");

if($mysidia->input->post("submit")){
$todayDate = new DateTime;
//H:i:s
$todayDate->setTimezone(new DateTimeZone('Europe/London'));
$date = $todayDate->format('Y-m-d H:i:s');
/*if(!$mysidia->input->post("newstitle")) throw new BlankFieldException("No title");
if(!$mysidia->input->post("newscontent")) throw new BlanKFieldException("No content");*/

($mysidia->input->post("allowcomments"))?$allow = "yes":$allow = "no";
($mysidia->input->post("allowmessage"))?$allowM = "yes":$allowM = "no";


if($mysidia->input->post("submit") == "submitDraft"){

$mysidia->db->insert("news",array("title" => $mysidia->input->post("newstitle"), "content" => $this->format($mysidia->input->post("pagecontent")), "user" => $mysidia->user->uid, "date" => $date, "posted" => "no","allowcomment" => $allow, "allowmessage" => $allowM));
}

else{

$mysidia->db->insert("news",array("title" => $mysidia->input->post("newstitle"), "content" => $this->format($mysidia->input->post("pagecontent")), "user" => $mysidia->user->uid, "date" => $date, "posted" => "yes","allowcomment" => $allow, "allowmessage" => $allowM));

if($mysidia->input->post("allowmessage")){
//NEW!
$allusers = $mysidia->db->select("users", array("username"), "");

$today = new DateTime;
$dateToday = $today->format('Y-m-d');
$messageTitle = "Update";
$messagetext = "A new news was posted on the site! Click <a href='/news'>here</a> to view!<br>";

while($user = $allusers->fetchColumn()){
$mysidia->db->insert("messages", array("fromuser" => "SYSTEM", "touser" => $user, "status" => "unread", "datesent" => $dateToday, "messagetitle" => $messageTitle, "messagetext" => $messagetext), "");
}

}
}
$document->add(new Comment("<b>Successfully changed news. Fill this page again to create a new post. Click <a href='/news' target='_blank'>here</a> to see the news page.</b>"));
}
$todayDate = new DateTime;
$date = $todayDate->format('Y-m-d');
$editor = $this->getField("editor")->get();
$form = new Form("title","","post");
$form->add(new Comment("<b>Date</b>:{$date} and <b>Author</b>: {$mysidia->user->username} and <b>Published</b>: No"));
$form->add(new Comment("<b>Title</b>:"));
$form->add(new TextField("newstitle",""));
$form->add(new Comment("<b>Contents</b>:"));
$form->add(new Comment($editor));
$comments = new CheckBox("Allow comments on this news", "allowcomments", 1, "array");
$comments2 = new CheckBox("Send message to all users notifying about the existence of an update", "allowmessage", 2, "array");
$form->add($comments);
$form->add($comments2);
$form->add(new Button("Save as draft","submit","submitDraft"));
$form->add(new Button("Publish","submit","submitPublish"));
$document->add($form);
}

private function format($text){
$text = html_entity_decode($text);
$text = stripslashes($text);
$text = str_replace("rn","",$text);
return $text;
}
}
?>

parayna
12-19-2014, 07:46 AM
Thank you IntoRain ^_^

IntoRain
12-19-2014, 02:29 PM
Thank you IntoRain ^_^

No problem! ^^

MikiHeart
01-16-2015, 03:46 AM
I really love your news script. Do you mind if I built on top of it?
I want to add more to it, like the ability to report comments for moderation.

I also have one concern, since the pagination just hides the other news, wouldn't it make the page heavy to load if you have like 100 news with images in each once? Or is it set to load when it's clicked. I don't know much about jQuery.

I also want to addon an archive system. So when a piece of news is a certain age, it will go into the archive, and can no longer be commented.

I also want to add a captcha to help prevent spam.

Kyttias
01-16-2015, 10:35 AM
Nah, paginated stuff isn't even pulled to load. Your adopts page is also paginated, past 10 pets or so. I can confirm by right clicking to inspect the source that pets past that number aren't even loaded, so, I assume the same for the news?

MikiHeart
01-16-2015, 10:52 AM
I hope so. I can't tell on my local server @.@ Because it loads fast.

Edit: Just a heads up, html can be submitted to the comment form. I tested to see if PHP works, but I couldn't get it to.
This should be roughly tested to make sure no one can put malicious code. @.@

IntoRain
01-16-2015, 12:58 PM
Ah, of course you can build on top of it! ^^ It's far from finished, I never got to polish it because of lack of time + motivation @_@ You can also share what you do with it here, if you want to!

Regarding the html thingies, you can go to the format() functions and use htmlentities() I believe, to convert the html characters to html entities.

I'm using my own pagination because at the time I was enchanted with javascript and wanted to try it, so it's not really optimized at all xD

MikiHeart
01-17-2015, 03:15 AM
I will share what I make for sure ^^
I want to put more links to the profile and pets and stuff in the comment box.
As well as implant a user siggy kinda thing. But the siggy will come later on when I build the forum.

MikiHeart
01-18-2015, 08:32 AM
What Pagination are you using now?
Also, what about comments? Do they use the Pagination too?

CallumCharlton
03-10-2015, 12:24 PM
Going to certainly add this to my site, or adapt it somewhat! Thanks so much! :3

IntoRain
03-10-2015, 01:48 PM
What Pagination are you using now?
Also, what about comments? Do they use the Pagination too?

One I created to learn jQuery at the time, so looking at it now it's not really optimized xD It's pretty much the javascript code in one of the files. The comments don't use pagination
If I had more time, I'd recode it x.x'

CallumCharlton
03-10-2015, 04:17 PM
You happen to be looking for work with a VPS? :pleased:

Ittermat
03-30-2016, 05:07 PM
I installed this and followed the instructions- but I seem to get this error when I got to create News from the acp


Strict Standards: Declaration of AdminSidebar::setDivision() should be compatible with Sidebar::setDivision(GUIComponent $module) in /home/atrocity/public_html/classes/class_adminsidebar.php on line 18

Fatal error: Uncaught exception 'Exception' with message 'Database error 1054 - Unknown column 'content' in 'field list'' in /home/atrocity/public_html/classes/class_database.php:213 Stack trace: #0 /home/atrocity/public_html/classes/class_database.php(117): Database->_query('news', Array, 'insert') #1 /home/atrocity/public_html/admincp/view/newsview.php(223): Database->insert('news', Array) #2 /home/atrocity/public_html/classes/class_frontcontroller.php(100): ACPNewsView->create() #3 /home/atrocity/public_html/admincp/index.php(109): FrontController->render() #4 /home/atrocity/public_html/admincp/index.php(113): AdminCP::main() #5 {main} thrown in /home/atrocity/public_html/classes/class_database.php on line 213

Im not entirely sure what i did wrong?

Suzanne
06-15-2016, 02:13 PM
Works perfectly. Thank you for offering this :-)

RinLin
08-06-2016, 06:20 PM
I get this error when trying to access the news.php page
Fatal error: Class 'AppController' not found in /home/digitalp/public_html/news.php on line 7

NobodysHero
08-29-2016, 12:07 AM
Just installed it on MystFell. It works great! I changed it around a little bit, but it works wonderfully! Thanks so much!

SilverDragonTears
01-13-2017, 12:23 PM
This works great, however how can I make this the index page?

goofyunicorn
02-27-2018, 06:22 AM
I get a fatal error when I try to create news. How do I fix this?

Dinocanid
02-27-2018, 08:19 AM
What does the error say?

goofyunicorn
02-27-2018, 09:56 AM
What does the error say?

Fatal error: Uncaught exception 'Exception' with message 'Fatal Error: Class ACPNewsView either does not exist, or has its include path misconfigured!' in /home/beausavi/public_html/classes/class_loader.php:83 Stack trace: #0 [internal function]: Loader->load('ACPNewsView') #1 /home/beausavi/public_html/classes/class_controller.php(135): spl_autoload_call('ACPNewsView') #2 /home/beausavi/public_html/classes/class_appcontroller.php(115): Controller->loadView(Object(Resource\Native\String)) #3 /home/beausavi/public_html/classes/class_frontcontroller.php(71): AppController->getView() #4 /home/beausavi/public_html/admincp/index.php(108): FrontController->getView() #5 /home/beausavi/public_html/admincp/index.php(113): AdminCP::main() #6 {main} thrown in /home/beausavi/public_html/classes/class_loader.php on line 83

Dinocanid
02-27-2018, 10:06 AM
It looks like you're missing ACPNewsView.php. Is it in the view folder?

goofyunicorn
02-27-2018, 10:14 AM
It looks like you're missing ACPNewsView.php. Is it in the view folder?


Yep I have it. AdminCP and then the View folder in there. :/

Dinocanid
02-27-2018, 10:54 AM
When you open the file, does it have this near the top:
class ACPNewsView extends View{

or this?:
class NewsView extends View{

goofyunicorn
02-27-2018, 10:57 AM
When you open the file, does it have this near the top:
class ACPNewsView extends View{

or this?:
class NewsView extends View{

class NewsView extends View{

It has this!

Dinocanid
02-27-2018, 11:03 AM
Oh! You put it in the wrong place then. (I figured that might be the issue, since both files have the exact same name)
Just copy-paste the code for the view file under the "Part 4: The AdminCP" section of the OP and it should work.
"ACPNewsView" needs to be in the view subfolder located in the adminCP folder, while "NewsView" needs to go in the main view folder located under public_html.

goofyunicorn
02-27-2018, 11:16 AM
Oh! You put it in the wrong place then. (I figured that might be the issue, since both files have the exact same name)
Just copy-paste the code for the view file under the "Part 4: The AdminCP" section of the OP and it should work.
"ACPNewsView" needs to be in the view subfolder located in the adminCP folder, while "NewsView" needs to go in the main view folder located under public_html.

It still doesn't come up. New error I think:

Fatal error: Uncaught exception 'Exception' with message 'Fatal Error: Class ACPNewsView either does not exist, or has its include path misconfigured!' in /home/beausavi/public_html/classes/class_loader.php:83 Stack trace: #0 [internal function]: Loader->load('ACPNewsView') #1 /home/beausavi/public_html/classes/class_controller.php(135): spl_autoload_call('ACPNewsView') #2 /home/beausavi/public_html/classes/class_appcontroller.php(115): Controller->loadView(Object(Resource\Native\String)) #3 /home/beausavi/public_html/classes/class_frontcontroller.php(71): AppController->getView() #4 /home/beausavi/public_html/admincp/index.php(108): FrontController->getView() #5 /home/beausavi/public_html/admincp/index.php(113): AdminCP::main() #6 {main} thrown in /home/beausavi/public_html/classes/class_loader.php on line 83

Dinocanid
02-27-2018, 11:27 AM
If you download the RAR file, the error still appears if you do this?:

Take the file from "Mys134 - News System\admincp\view\newsview.php" and place it in "public_html\admincp\view" (make sure to overwrite the existing file if it asks)
Take the file from "Mys134 - News System\views\newsview.php" and place it in "public_html\view"


I'm sure error has something to do with where you placed it, since the script itself runs fine without changes.

goofyunicorn
02-27-2018, 11:45 AM
If you download the RAR file, the error still appears if you do this?:

Take the file from "Mys134 - News System\admincp\view\newsview.php" and place it in "public_html\admincp\view" (make sure to overwrite the existing file if it asks)
Take the file from "Mys134 - News System\views\newsview.php" and place it in "public_html\view"


I'm sure error has something to do with where you placed it, since the script itself runs fine without changes.

Yay! We are working :D

One more thing, now when I go to my website it comes up with this to do with the themes:
Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'template.tpl'' in /home/beausavi/public_html/inc/smarty/sysplugins/smarty_internal_templatebase.php:127 Stack trace: #0 /home/beausavi/public_html/inc/smarty/sysplugins/smarty_internal_templatebase.php(374): Smarty_Internal_TemplateBase->fetch('template.tpl', NULL, NULL, NULL, true) #1 /home/beausavi/public_html/classes/class_template.php(135): Smarty_Internal_TemplateBase->display('template.tpl') #2 /home/beausavi/public_html/classes/class_view.php(280): Template->output() #3 /home/beausavi/public_html/classes/class_frontcontroller.php(102): View->render() #4 /home/beausavi/public_html/index.php(74): FrontController->render() #5 /home/beausavi/public_html/index.php(78): IndexController::main() #6 {main} thrown in /home/beausavi/public_html/inc/smarty/sysplugins/smarty_internal_templatebase.php on line 127

Dinocanid
02-27-2018, 11:52 AM
What page does this show up on?

goofyunicorn
02-27-2018, 11:56 AM
What page does this show up on?

When I type in the webaddress on any page.

Dinocanid
02-27-2018, 12:37 PM
The site appears fine for me, and I tried all 3 of the themes from the changestyle page. If you go to phpMyAdmin and look under the user settings table, what does it say for your chosen theme?

goofyunicorn
02-27-2018, 01:09 PM
The site appears fine for me, and I tried all 3 of the themes from the changestyle page. If you go to phpMyAdmin and look under the user settings table, what does it say for your chosen theme?


It seems to be just on my laptop. One more question, how do I make a support ticket page?

Dinocanid
02-27-2018, 05:35 PM
It seems to be just on my laptop. One more question, how do I make a support ticket page?

I actually have code lying around for that, which I haven't even used tbh. I'll look for it and make a topic for it