<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Forums - Bricks in Motion - Admin generated news box on website]]></title>
		<link>https://bricksinmotion.com/forums/topic/4632/admin-generated-news-box-on-website/</link>
		<description><![CDATA[The most recent posts in Admin generated news box on website.]]></description>
		<lastBuildDate>Tue, 15 Dec 2009 11:37:03 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Admin generated news box on website]]></title>
			<link>https://bricksinmotion.com/forums/post/100828/#p100828</link>
			<description><![CDATA[Yes and no.

I've been dabling with websites since 2001 but I've never really "developed" anything. I mainly just hand-code ultra-basic html and now getting into php since it is so useful. Javascript? No idea on that one. I can do rudimentary flash, but nothing really exciting or interesting. I've got a smattering of sites around the web that I've built either for myself or for others, but nothing to get excited over.]]></description>
			<author><![CDATA[dummy@example.com (Dr Neo Lao)]]></author>
			<pubDate>Tue, 15 Dec 2009 11:37:03 +0000</pubDate>
			<guid>https://bricksinmotion.com/forums/post/100828/#p100828</guid>
		</item>
		<item>
			<title><![CDATA[Re: Admin generated news box on website]]></title>
			<link>https://bricksinmotion.com/forums/post/100370/#p100370</link>
			<description><![CDATA[If you wanted to execute PHP via the textbox (highly insecure, I do not recommend it) you put it like eval(nl2br(file_get_contents('admin.txt')));

Are you a web developer now then Leo?]]></description>
			<author><![CDATA[dummy@example.com (Aled Owen)]]></author>
			<pubDate>Sun, 13 Dec 2009 17:20:37 +0000</pubDate>
			<guid>https://bricksinmotion.com/forums/post/100370/#p100370</guid>
		</item>
		<item>
			<title><![CDATA[Re: Admin generated news box on website]]></title>
			<link>https://bricksinmotion.com/forums/post/100305/#p100305</link>
			<description><![CDATA[@Littlebrick - It does. If you feed through basic html (such as links) they get parsed correctly, not too sure about php. Feeding through simple php (such as a single argument) ought to work but the first ; would kill the data feed. I don't think it would work very well for major page entities (such as the layout and stylesheets).

@lil'jj - I agree with you on that one in principle, but it's not for my site and the person requesting this has their dear little heart set on scrolling text. I'd do it better with javascript or something but the <marquee> tag is there, it works and I can't be bothered putting in the extra effort to make it nicer in the code to have the same result on the outside.

At any rate, I got the nut cracked, so I'm happy with the end result. Thanks to everyone and especially thanks to Aled.]]></description>
			<author><![CDATA[dummy@example.com (Dr Neo Lao)]]></author>
			<pubDate>Sun, 13 Dec 2009 09:05:58 +0000</pubDate>
			<guid>https://bricksinmotion.com/forums/post/100305/#p100305</guid>
		</item>
		<item>
			<title><![CDATA[Re: Admin generated news box on website]]></title>
			<link>https://bricksinmotion.com/forums/post/100255/#p100255</link>
			<description><![CDATA[I like it, the only problem is, ditch the <marque> tag. That's old school HTML]]></description>
			<author><![CDATA[jacobjumper@gmail.com (lil'jj)]]></author>
			<pubDate>Sun, 13 Dec 2009 00:02:14 +0000</pubDate>
			<guid>https://bricksinmotion.com/forums/post/100255/#p100255</guid>
		</item>
		<item>
			<title><![CDATA[Re: Admin generated news box on website]]></title>
			<link>https://bricksinmotion.com/forums/post/100248/#p100248</link>
			<description><![CDATA[Does that box support HTML/PHP code, or whatever you may be using? It would be nice to edit most of the page (think images and fonts/colors/sizes, etc) online.]]></description>
			<author><![CDATA[graemecallen@yahoo.com (Littlebrick)]]></author>
			<pubDate>Sat, 12 Dec 2009 23:37:47 +0000</pubDate>
			<guid>https://bricksinmotion.com/forums/post/100248/#p100248</guid>
		</item>
		<item>
			<title><![CDATA[Re: Admin generated news box on website]]></title>
			<link>https://bricksinmotion.com/forums/post/100245/#p100245</link>
			<description><![CDATA[Yes! Someone on another forum pointed out how to do this - there is a php command that will do it - [url=http://au.php.net/manual/en/function.nl2br.php]nl2br[/url].

Usage:
[code]<?php
$comment = file_get_contents('admin.txt'); 
echo nl2br ($comment);
?>[/code]

So going on from Aled's code, the first line will read whatever is in the file admin.txt and the second line will display it on the screen. Adding the "nl2br" bit means that any line breaks in admin.txt will be displayed.

Thanks everyone!]]></description>
			<author><![CDATA[dummy@example.com (Dr Neo Lao)]]></author>
			<pubDate>Sat, 12 Dec 2009 22:24:25 +0000</pubDate>
			<guid>https://bricksinmotion.com/forums/post/100245/#p100245</guid>
		</item>
		<item>
			<title><![CDATA[Re: Admin generated news box on website]]></title>
			<link>https://bricksinmotion.com/forums/post/100055/#p100055</link>
			<description><![CDATA[Thanks Aled, that's awesome!

It works great for the first part (working sample [url=http://escobar.id.au/test/index.php]here[/url]) but I can't figure out how to get it to do the second part (multiple paragraphs).

The main issue is that the admin using this script is not code savvy and won't know to use \n for new lines (or <br> or other codes).

Is there a way to get php to echo a block of text the way it is written in the text file (as it does in a forum, for example) or does that need more complex database functions (I downloaded phpBB for a quick peek at the php code and couldn't make sense of it :( ).]]></description>
			<author><![CDATA[dummy@example.com (Dr Neo Lao)]]></author>
			<pubDate>Fri, 11 Dec 2009 23:48:18 +0000</pubDate>
			<guid>https://bricksinmotion.com/forums/post/100055/#p100055</guid>
		</item>
		<item>
			<title><![CDATA[Re: Admin generated news box on website]]></title>
			<link>https://bricksinmotion.com/forums/post/99960/#p99960</link>
			<description><![CDATA[:twitch: !@#$ awesome beans Aled :P]]></description>
			<author><![CDATA[steengrover@gmail.com (Capedkid)]]></author>
			<pubDate>Fri, 11 Dec 2009 14:04:53 +0000</pubDate>
			<guid>https://bricksinmotion.com/forums/post/99960/#p99960</guid>
		</item>
		<item>
			<title><![CDATA[Re: Admin generated news box on website]]></title>
			<link>https://bricksinmotion.com/forums/post/99959/#p99959</link>
			<description><![CDATA[So you don't want to use an FTP file to update the text file.

You can go about it by using a PHP function fwrite(); to actually write the postdata to the file, something like this:

input.php

[code]
$myFile = "admin.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, stripslashes($_POST['yayinput']));
fclose($fh);
[/code]

post.php

[code]
<html>
<head>
<title>Post</title>
</head>
<body>
<form action="input.php" method="post">
<textarea name="yayinput"><?php echo file_get_contents('admin.txt'); ?></textarea><br />
<input type="submit" value="Go!" name="submit">
</form>
</body>
</html>
[/code]

I don't know if that'll work and it's highly basic but basically what it does is what you want, you can probably insert some nice jazz into it but for a 2 minute job at lunchtime at school it's alright.]]></description>
			<author><![CDATA[dummy@example.com (Aled Owen)]]></author>
			<pubDate>Fri, 11 Dec 2009 13:51:43 +0000</pubDate>
			<guid>https://bricksinmotion.com/forums/post/99959/#p99959</guid>
		</item>
		<item>
			<title><![CDATA[Re: Admin generated news box on website]]></title>
			<link>https://bricksinmotion.com/forums/post/99946/#p99946</link>
			<description><![CDATA[That's a nifty way of summing it up, yes.

Admin visits site via browser, logs in, types new news and clicks "update". New news now visible.]]></description>
			<author><![CDATA[dummy@example.com (Dr Neo Lao)]]></author>
			<pubDate>Fri, 11 Dec 2009 10:29:37 +0000</pubDate>
			<guid>https://bricksinmotion.com/forums/post/99946/#p99946</guid>
		</item>
		<item>
			<title><![CDATA[Re: Admin generated news box on website]]></title>
			<link>https://bricksinmotion.com/forums/post/99851/#p99851</link>
			<description><![CDATA[So if I understand correctly, you want a GUI for the admins to update news, sans having to editing actual pages.]]></description>
			<author><![CDATA[fib12345@brickmation.net (fib12345)]]></author>
			<pubDate>Thu, 10 Dec 2009 23:53:47 +0000</pubDate>
			<guid>https://bricksinmotion.com/forums/post/99851/#p99851</guid>
		</item>
		<item>
			<title><![CDATA[Admin generated news box on website]]></title>
			<link>https://bricksinmotion.com/forums/post/99819/#p99819</link>
			<description><![CDATA[Hi everybody! This is a html type question, so I guess this is the best spot for it.

I have a procedural question. Odds are that there are already a dozen tutorials out there for exactly what I want, but I'm not asking the right questions. I figure asking humans will hopefully get me pointed in the right direction rather than relying on Google's algorythms.

[b]Challenge:[/b] I have responsibilityfor a site which has on its front page two news spots - one for a one-line "quick" news update and one for a longer, multi-paragraph news block (by "news" I mean whatever the admin wants to put on there).

The site is all hand coded with no CMS. I am comfortable with php and have MySql available (but not currently using it).

[b]Current Workaround:[/b] The page currently uses php include to import an external text file which has both news items plus sundries (like footer information). Editing this file by hand and uploading via FTP is what is currently being done by me after receiving an email with the new news from the admin.

[b]Desired Solution:[/b] I want to set it up so that the admin can update the news themselves. They are not web savvy nor know their way around an FTP program.

So far, I think what can be done is this:[list=*]
[*]Set up a folder "admin" and seal that off via .htaccess. This will allow the admin to log in via their browser with no third programs needed.[/*]
[*]In that section, have some forms (or a single form) that will allow the admin to input the new data. Presumably the target for said form(s) would need to be "update file".[/*]
[*]To my mind, either the form(s) would need to edit a text file which would then be read by the index, or the form(s) would need to update a database (which would then be read by the index).[/*]
[/list]It is this third part that I am stuck on. I think I have the theory right, but how to actually go about coding it I am not so sure of.

Any tips or links to tutorials?]]></description>
			<author><![CDATA[dummy@example.com (Dr Neo Lao)]]></author>
			<pubDate>Thu, 10 Dec 2009 21:36:49 +0000</pubDate>
			<guid>https://bricksinmotion.com/forums/post/99819/#p99819</guid>
		</item>
	</channel>
</rss>
