So if you have any special characters and you are not using this function, then it might trigger an error in your RSS feed. Since XML do not interpret special characters. You can see that we are using htmlspecialchars() function which helps to convert special characters into HTML entities. Then we are connecting with the database and fetching all the latest products in descending order (newest to oldest). For getting website main URL we will be using PHP built-in SERVER variable and SERVER_NAME will return the name of the server which in this case will be localhost, and REQUEST_URI will return the address of folder from where this script is getting executed. The link must be your website’s main URL and language can be in one of the standard language codes. Then we have title, description, link and url tags, they will be used to explain the properties of channel tag. For example, you might have an E-commerce site and also the latest blog posts from one of your blog site. So you can put different data in different channel tags. Ĭhannel tag will be served as a category since you might have different types of data on your website. We will be using this variable when creating an XML file. Then we are creating a string variable $str that will hold all the RSS feed value in string format. But we are trying to make it dynamic so you won’t have difficulty when moving to different domains. You can just set this variable a static value. "" įirst we are creating a variable $web_url that will hold the base URL of the website. htmlspecialchars($row->productDescription). While ($row = mysqli_fetch_object($result)) $result = mysqli_query($conn, "SELECT * FROM products ORDER BY productCode DESC") $conn = mysqli_connect("localhost", "root", "", "classicmodels") The standard format of creating an RSS feed is: Then will automatically be notified when you upload something new on your website. User can then add that RSS link in this RSS aggregator software. One common practice is to create an anchor tag in HTML that will redirect the user to that XML file. We will be using the second technique in this tutorial.Īlso, you will need to create a button on your website’s main page from where users can see your feeds. Or you can add a function that will create or update an XML file whenever you post something new on your website. Then you can upload it manually using your cPanel file manager. You can either create a button on the admin panel to generate feeds and export the XML file. There are multiple ways to create an RSS feed for your website and different people adopt different ways, that’s okay. There are a lot of tags which can be used in RSS but the most common are title, description, link, language, image, url, category, copyright and author. So you must follow the rules and proper tags of XML to reach the global audience. They follow a specific pattern to read and display feeds to users. The programs or scripts that are used to read these feeds are known as RSS aggregators. If your feed has some special characters like a single or double quote, you need to convert them to HTML entities before publishing or updating your feed. RSS feeds are XML files, so they must follow all the standard formats of XML. Then your RSS feed will be about the latest posts that you have published on your blog. Then creating an RSS feed will help visitors to view the latest products on your website. Examplesįor example, if you are running an E-commerce site. Programs known as RSS aggregators are created which reads the feed in XML format in a standardized way. It is a form of web feed that allows other computer programs to fetch updates about the website. RSS feed is formerly known as RDF Site Summary feed, now it stands for Really Simple Syndication.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |