简体   繁体   English

将帖子添加到博客类型网站的方法

[英]Approach for adding posts to a blog type website

I've created a blog style website using html, CSS and bootstrap.我使用 html、CSS 和引导程序创建了一个博客风格的网站。 I've recently started learning Javascript.我最近开始学习 Javascript。

I want to be able to add/delete posts etc to the blog website.我希望能够在博客网站上添加/删除帖子等。 Is Javascript the technology I should be using to do to this? Javascript 是我应该使用的技术吗? I also thought I could use SQL or something to create a database and somehow have posts be loaded onto the site from the database.我还认为我可以使用 SQL 或其他东西来创建数据库,并以某种方式将帖子从数据库加载到网站上。

I'm pretty new to all this so I'm not too sure.我对这一切都很陌生,所以我不太确定。

Help appreciated.帮助表示赞赏。

What you need is some sort of storing the objects on a server.您需要的是某种将对象存储在服务器上的方法。 You can choose from plethora of solutions, naming php and nodejs as most popular ones in web world.您可以从众多解决方案中进行选择,将 php 和 nodejs 命名为 web 世界中最流行的解决方案。 On the server you (most of the times) make a connection to the database (sql - mysql, mariadb etc or nosql like mongodb for example) in order to get or set or remove some objects (posts). On the server you (most of the times) make a connection to the database (sql - mysql, mariadb etc or nosql like mongodb for example) in order to get or set or remove some objects (posts). You can as well store it in files or whatever you want, but database is just created to serve this purpose.您也可以将其存储在文件或任何您想要的东西中,但是数据库只是为了这个目的而创建的。 Has numerous advantages over another solutions.与其他解决方案相比具有众多优势。

And now to the Javascript;现在到 Javascript; you can use it to send the data asynchronously (read about ajax / xhr request) but its completely optional.您可以使用它异步发送数据(阅读有关 ajax / xhr 请求),但它完全是可选的。 It's definetely not the core of the proces and it's completely ommitable.它绝对不是过程的核心,它是完全可以忽略的。

You can build anything from scratch, and such experiments are sometimes beneficial, but most of the times you just want to use some de-facto standard technology that has most of the pitfalls covered and offers you good development experience as well as security benefits (wordpress - cms, symfony frsmework).你可以从头开始构建任何东西,这样的实验有时是有益的,但大多数时候你只是想使用一些事实上的标准技术,它涵盖了大部分的陷阱,并为你提供了良好的开发体验和安全优势(wordpress - 厘米,symfony frsmework)。

You will definitely have to use JS to dynamically add blog posts to your website.您肯定必须使用 JS 将博客文章动态添加到您的网站。 You can create an array of objects, that contain the info of your posts - eg (title, content, datepublished, etc.) and you can then use the map method ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map ) to map this array onto a page, so that each post appears as a separate div.您可以创建一个包含帖子信息的对象数组 - 例如(标题、内容、发布日期等),然后您可以使用 map 方法( https://developer.mozilla.org/en-US/ docs/Web/JavaScript/Reference/Global_Objects/Array/map ) 到 map 将此数组放到一个页面上,以便每个帖子显示为一个单独的 div。

You can also link a SQL database or any other database to your site, as well.您也可以将 SQL 数据库或任何其他数据库链接到您的站点。 That's not a problem.这不是问题。

Hope that helps.希望有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM