Reputation: 9
i am making a website that will feature many articles that will always be changing, i am trying to find a way to quickly change the text in these articles as i am the only person who knows the code in the company.
I was thinking of having a text document or something that has the articles text and when it gets changed so does the text on the site.I just dont know how to implement this.
sorry if its hard to understand what i mean, im not too familiar with sleep these days.
Upvotes: 0
Views: 41
Reputation: 16056
You don't need any dynamic server code like the other answers are suggesting. Either a "static site generator" (there are uncountably many, but that should give you something to Google if my main answer doesn't satisfy you) or a client-side scripting.
XSLT was designed for this exact problem. It can be run client-side or server-side with xsltproc
(for compatibility with dumb clients). XSLT 1.0 is well-supported by all common browsers, though if you need EXSLT extensions in IE you had to add shims. Note that Webkit-based browsers can't do XSLT on file://
URLs, either set up a local HTTP server or use Firefox.
I have a minimal example site set up here that includes multiple files in one page: https://o11c.github.io/foo-test/foo-root.xml
foo-style.xml:
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/index"> <html> <body> <h2>Merge test</h2> <table border="1"> <tr> <th>Attr</th> <th>Value</th> </tr> <xsl:apply-templates select="document(include/@name)"/> </table> </body> </html> </xsl:template> <xsl:template match="root"> <xsl:for-each select="foo"> <tr> <td><xsl:value-of select="@x"/></td> <td><xsl:value-of select="text()"/></td> </tr> </xsl:for-each> </xsl:template> <xsl:template name="identity"> <xsl:copy> <xsl:for-each select="node()|@*"> <xsl:call-template name="identity"/> </xsl:for-each> </xsl:copy> </xsl:template> </xsl:stylesheet>
foo-root.xml:
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="foo-style.xslt"?> <index> <include name="foo-1.xml"/> <include name="foo-2.xml"/> </index>
foo-1.xml:
<?xml version="1.0"?> <root> <foo x="a">aa</foo> <foo x="b">bb</foo> <foo x="c">cc</foo> </root>
foo-2.xml:
<?xml version="1.0"?> <root> <foo x="d">dd</foo> <foo x="e">ee</foo> <foo x="f">ff</foo> </root>
Further resources:
node-set
in particular is very useful.xsltproc
webpageUpvotes: 1
Reputation: 430
Well you might do this using php and Mysql You can easily display save the articles in mysql and you could create a simple user interface for the people respnsible for editing the code to edit it too easy
Upvotes: 0
Reputation: 221
You could use wordpress, if you are building the site from scratch and not adding to an existing one. This will allow you to edit articles in a user friendly interface that will allow you to style the text and will be easier for other people in the company to edit as well. It's very fast to set up.
Or you could just keep the written text in the HTML file itself, but this may make it harder to maintain and style, and those not technical savvy may not be able to edit it or will end up breaking it.
Upvotes: 0