Jump to content
  • 0

Frame Flux CMS News to Thor Notices Box


Question

Posted (edited)

Hi there. Like title says, I'm trying to frame calciumkid's Flux CMS news section into Thor Patcher notices box so I wouldn't have to write the updates to notice.html manually. I just want the news section to embed in patcher, iFrame won't do the jobs :(

vd0u2.png

I4mgI.png

Thks in advance.

Edited by darristan

15 answers to this question

Recommended Posts

Posted (edited)

Thks for the reply JayPee, but FluxCP's php structure is kind of difficult to understand. I have no idea where should I start.

I have the index.php for the CMS news here, so which ajax codes should I place in the patcher notice page to let it fetches news query here?

<?php
/*-------------------------------------
// Created by: Harrison aka CalciumKid
---------------------------------------
// Released Exclusively for the RAthena
// development boards. Please do not
// redistribute my work without
// permission and leave all credits in
// tact.
---------------------------------------
// !!!THIS WORK IS COPYRIGHTED!!!
// Contact: [email protected]
-------------------------------------*/
if (!defined('FLUX_ROOT')) exit;  
$this->loginRequired();
?>
<h2><?php echo htmlspecialchars(Flux::message('NewsPage')) ?></h2>
<p>This news management system is an Add-on of Flux Control Panel. This allows you to add, edit, delete news.</p>
<?php if($news): ?>
<table class="horizontal-table" width="100%">
 <tr>
  <th><?php echo htmlspecialchars(Flux::message('NewsTitleLabel')) ?></th>  
  <th><?php echo htmlspecialchars(Flux::message('NewsAuthorLabel')) ?></th>  
  <th><?php echo htmlspecialchars(Flux::message('CreatedLabel')) ?></th>
  <th><?php echo htmlspecialchars(Flux::message('ModifiedLabel')) ?></th>
  <th><?php echo htmlspecialchars(Flux::message('ActionLabel')) ?></th>  
 </tr>
 <?php foreach($news as $nrow):?>
  <tr>
<td><?php echo $nrow->title?></td>
<td><?php echo $nrow->author?></td>
<td><?php echo date('d-m-Y',strtotime($nrow->created))?></td>
<td><?php echo date('d-m-Y',strtotime($nrow->modified))?></td>
<td>
 <a href="<?php echo $this->url('news', 'edit', array('id' => $nrow->id)); ?>">Edit</a> |
 <a href="<?php echo $this->url('news', 'delete', array('id' => $nrow->id)); ?>" onclick="return confirm('<?php echo htmlspecialchars(Flux::message('ConfirmLabel')) ?>');">Delete</a>
</td>
  </tr>
 <?php endforeach;?>
</table>
<?php else: ?>
<p>
 <?php echo htmlspecialchars(Flux::message('NewsEmpty')) ?><br/><br/>
 <a href="<?php echo $this->url('news', 'add') ?>"><?php echo htmlspecialchars(Flux::message('CreateLabel')) ?></a>
</p>
<?php endif ?>

Thks again.

Edited by darristan
Posted

Hello, if this is not yet solved here is my sample program that will get the news in your fluxcp

Note:

  • I use calciumkid fluxcp CMS Addson here
  • You need to edit fluxcpnews.html and edit also the url in the javascript inside the HTML file
  • This program use jquery library it is also included in the rar file

flucxpajax.rar

Posted

Well. Thks for the code anyway but it couldn't work either... Alright here's my web docs directory structure. I changed the url in html to my IP but it doesnt work still :D

You mentioned You need to edit fluxcpnews.html and edit also the url in the javascript inside the HTML file and what was the thing I have to edit other than URL?

Ne94b.png

Posted

CP is working and it's placed on root of my web docs, patch.html is in /patch/ folder with all patches files there.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>News & Notices</title>
</head>
<body>
<script type="text/javascript" language="javascript" src="jquery-1.6.2.min.js"></script>
<div class="cp_news"></div>
<script type="text/javascript" language="javascript">
$(document).ready(function(){
//cpurl is the address or URL of your fluxcp view you may change them
var cpurl = "http://flarismro.no-ip.org:8080/index.php?module=news&action=view";
$.ajax({
 type:"GET",
 url:cpurl,
 cache:false,
 success:function(data){
  /*
   Explanation:
 .newsDiv is the class name of the div tag in your fluxcp news view
 .cp_news is the class name of the div tag where in contents get from your fluxcp news will be posted
  */
  var content = $(data).find('.newsDiv').html(); //Get the news content only
  $('.cp_news').html(content); //Post the news
 }
})
});
</script>
</body>
</html>

Posted

It seems no-ip.org is denying the ajax process so thats why it returns nothing or an error. The solution i made is using php function file_get_contents just to get the content of your news page. Then I change notice.html url to flarismnews.php. So when notice.html is opened or visited it will get the content of flarismnews.php in which flarismnews.php will get the content of your fluxCP news and the notice.html jquery ajax will filter the contents of the flarismnews.php.

Try this

flarism.rar

There will be two files notice.html and flarismnews.php

Open flarismnews.php in a text editor and edit the $url variable to your desired address.

Posted (edited)

Doesn't work either but I have an idea, easier way to do it perhaps. Since calciumkid's CMS writes data into MySQL table, why not making a PHP scripts with MySQL logging then fetch data from CP_News table? But I have no idea how to do it, might need ur help once again. :[

qR2lS.png

Edited by darristan
Posted

Here:


<?php 
/*SQL Configuration*/
$address = "localhost"; //Database Address
$username = "root"; //Database Username
$password = "root"; //Database Password
$database = "test_3ceam"; //Database Name
$connect = mysql_connect($address,$username,$password) or die("Cant connect to the database");
$select_db = mysql_select_db($database,$connect) or die("Failed to connect to the database");
/*SQL Query*/
$query = "SELECT * FROM `cp_news` ORDER BY modified DESC";
$sql = mysql_query($query) or die("Failed to make select query command");
?>
<html>
<head>
<title>Notice</title>
<style type="text/css">
body
{
margin:0px;
font-family:Arial,Tahoma,Verdanna;
}
th
{
font-weight:bolder;
font-size:9pt;
padding:5px;
}
td
{
padding:5px;
font-size:9pt;
}
</style>
</head>
<body>
<?php while($fetch = mysql_fetch_array($sql)){ ?>
<table cellpadding="0" cellspacing="0" style="margin-bottom:10px;">
<tr>
<th>
[<?php echo htmlspecialchars($fetch['created']); ?>] - <?php echo htmlspecialchars($fetch['title']); ?>
</th>
</tr>
<tr>
<td>
<?php echo $fetch['body']; ?>
</td>
</tr>
<tr>
<td align="right">
Posted by: <?php echo $fetch['author']; ?>
</td>
</tr>
</table>
<?php } ?>
</body>
</html>

  • Upvote 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...