♥GLWalker Posted March 19, 2008 Posted March 19, 2008 Im working on formating an rss feed for the articles manager. Anyway Ive got it all working and Im adding the keywords in too. Problem is I need a line break between the description and keywords, Ive tried a few different formats and I keep breaking the code. Heres what Im using: echo ' <description>'; echo $desc; echo $keyw; echo '</description>' . "\n"; Anyone know what I can place between echo $desc; and echo $keyw; to get a line break? I placed the $keyw in its own tag already, but that wasnt really desirable. Thanks Follow the community build: BS3 to osCommerce Responsive from the Get Go! Check out the new construction: Admin Gone to Total BS!
germ Posted March 19, 2008 Posted March 19, 2008 I'm prettty sure you've already tried the usual ( <br> \n or both ). Can you point me to "the code" we're trying hard not to break? :unsure: I love a challenge. :rolleyes: If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
box25 Posted March 19, 2008 Posted March 19, 2008 Im working on formating an rss feed for the articles manager. Anyway Ive got it all working and Im adding the keywords in too. Problem is I need a line break between the description and keywords, Ive tried a few different formats and I keep breaking the code. Heres what Im using: echo ' <description>'; echo $desc; echo $keyw; echo '</description>' . "\n"; Anyone know what I can place between echo $desc; and echo $keyw; to get a line break? I placed the $keyw in its own tag already, but that wasnt really desirable. Thanks Have you tried echo '<description> . "\n"; echo $desc . "\n"; echo $keyw . "\n"; echo '</description>';
♥GLWalker Posted March 20, 2008 Author Posted March 20, 2008 Ive tried the /n and <br> tags wrapped in quotes, out of quotes and all kinds of ways. Its working as is, but its running the description and keywords together. If I uncomment the extra tag for the keywords below the description they only show up viewing the page source(which may be a good thing). Thanks Heres the file: <?php /* $Id: rss.php,v 1.22 2007/04/13 13:04:02 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); $navigation->remove_current_page(); $connection = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD) or die('Couldn\'t make connection.'); // Select database $db = mysql_select_db(DB_DATABASE, $connection) or die(mysql_error()); // If the language is not specified if ($_GET['language'] == '') { $lang_query = tep_db_query('select languages_id, code from ' . TABLE_LANGUAGES . ' where directory = \'' . $language . '\''); } else { $cur_language = tep_db_output($_GET['language']); $lang_query = tep_db_query('select languages_id, code from ' . TABLE_LANGUAGES . ' where code = \'' . $cur_language . '\''); } // Recover the code (fr, en, etc) and the id (1, 2, etc) of the current language if (tep_db_num_rows($lang_query)) { $lang_a = tep_db_fetch_array($lang_query); $lang_code = $lang_a['code']; $lang_id = $lang_a['languages_id']; } // If the default of your catalog is not what you want in your RSS feed, then // please change this three constants: // Enter an appropriate title for your website define(RSS_TITLE, STORE_NAME); // Enter your main shopping cart link define(WEBLINK, HTTP_SERVER); // Enter a description of your shopping cart define(DESCRIPTION, TITLE); ///////////////////////////////////////////////////////////// //That's it. No More Editing (Unless you renamed DB tables or need to switch //to SEO links (Apache Rewrite URL) ///////////////////////////////////////////////////////////// $store_name = STORE_NAME; $rss_title = RSS_TITLE; $weblink = WEBLINK; $description = DESCRIPTION; $email_address = STORE_OWNER_EMAIL_ADDRESS; // Encoding to UTF-8 $store_name = utf8_encode ($store_name); $rss_title = utf8_encode ($rss_title); $weblink = utf8_encode ($weblink); $description = utf8_encode ($description); $email_address = utf8_encode ($email_address); // Begin sending of the data Header('Content-Type: application/xml'); echo '<?xml version="1.0" encoding="UTF-8" ?>' . "\n"; echo '<?xml-stylesheet href="http://www.w3.org/2000/08/w3c-synd/style.css" type="text/css"?>' . "\n"; echo '<!-- RSS for ' . $store_name . ', generated on ' . date(r) . ' -->' . "\n"; ?> <rss version="2.0" xmlns:ecommerce="http://shopping.discovery.com/erss/" xmlns:media="http://search.yahoo.com/mrss/"> <channel> <title><?php echo $rss_title; ?></title> <link><?php echo $weblink;?></link> <description><?php echo $description; ?></description> <webMaster><?php echo $email_address; ?></webMaster> <language><?php echo $lang_code; ?></language> <lastBuildDate><?php echo date(r); ?></lastBuildDate> <image> <url><?php echo $weblink . '/images/rss_logo.jpg';?></url> <title><?php echo $rss_title; ?></title> <link><?php echo $weblink;?></link> <description><?php echo $description; ?></description> </image> <docs>http://blogs.law.harvard.edu/tech/rss</docs> <?php // Create SQL statement $topic = preg_replace('/[^0-9_]/', '', $_GET['tPath']); $ecommerce = $_GET['ecommerce']; if ($topic != '') { // Check to see if we are in a subcategory if (strrpos($topic, '_') > 0) { $topic = substr($topic, strrpos($topic, '_') + 1, strlen($topic)); } $topTable = ", articles_to_topics pc "; $topWhere = 'a.articles_id = at.articles_id AND at.topics_id = \'' . $topic . '\' AND '; } $sql = "SELECT a.articles_id, a.articles_date_added, ad.articles_name, ad.articles_description, ad.articles_head_keywords_tag, au.authors_name, td.topics_name FROM articles a $topTable LEFT JOIN articles_description ad ON ad.articles_id = a.articles_id AND ad.language_id = '$lang_id' LEFT JOIN authors au ON au.authors_id = a.authors_id LEFT JOIN articles_to_topics a2t ON a2t.articles_id=a.articles_id LEFT JOIN topics_description td ON a2t.topics_id = td.topics_id AND td.language_id = '$lang_id' WHERE $topWhere a.articles_status=1 AND a.articles_to_rss=1 GROUP BY a.articles_id ORDER BY a.articles_id DESC LIMIT " . MAX_RSS_ARTICLES; // Execute SQL query and get result $sql_result = mysql_query($sql,$connection) or die("Couldn\'t execute query:<br />$sql"); // Format results by row while ($row = mysql_fetch_array($sql_result)) { $id = $row['articles_id']; // RSS Links for Ultimate SEO (Gareth Houston 10 May 2005) $link = tep_href_link(FILENAME_ARTICLE_INFO, 'articles_id=' . $id, 'NONSSL', false); $added = date(r,strtotime($row['articles_date_added'])); // Setting and cleaning the data $name = $row['articles_name']; $desc = $row['articles_description']; $keyw = $row['articles_head_keywords_tag']; // Encoding to UTF-8 $name = utf8_encode ($name); $desc = utf8_encode ($desc); $keyw = utf8_encode ($keyw); $link = utf8_encode ($link); $author = $row['authors_name']; $author = utf8_encode ($author); $top_name = $row['topics_name']; // Encoding to UTF-8 $top_name = utf8_encode ($top_name); // http://www.w3.org/TR/REC-xml/#dt-chardata // The ampersand character (&) and the left angle bracket (<) MUST NOT appear in their literal form $name = str_replace('&','&',$name); $desc = str_replace('&','&',$desc); $keyw = str_replace('&','&',$keyw); $link = str_replace('&','&',$link); $top_name = str_replace('&','&',$top_name); $name = str_replace('<','<',$name); $desc = str_replace('<','<',$desc); $keyw = str_replace('<','<',$keyw); $link = str_replace('<','<',$link); $top_name = str_replace('<','<',$top_name); $name = str_replace('>','>',$name); $desc = str_replace('>','>',$desc); $keyw = str_replace('>','>',$keyw); $link = str_replace('>','>',$link); $top_name = str_replace('>','>',$top_name); // Writing the output echo '<item>' . "\n"; echo ' <title>' . $name . '</title>' . "\n"; echo ' <topic>' . $top_name . '</topic>' . "\n"; echo ' <link>' . $link . '</link>' . "\n"; echo ' <description>'; echo $desc; echo $keyw; echo '</description>' . "\n"; //echo ' <keywords>' . $keyw . '</keywords>' . "\n"; echo ' <guid>' . $link . '</guid>' . "\n"; echo ' <pubDate>' . $added . '</pubDate>' . "\n"; if($ecommerce!='') { echo ' <ecommerce:author>' . $author . '</ecommerce:author>' . "\n"; } echo '</item>' . "\n"; } // Free resources and close connection mysql_free_result($sql_result); mysql_close($connection); ?> </channel> </rss> Follow the community build: BS3 to osCommerce Responsive from the Get Go! Check out the new construction: Admin Gone to Total BS!
germ Posted March 20, 2008 Posted March 20, 2008 I don't know if what you are trying to do is possible. A reference link: RSS 1.0 From that page: Encoding HTML — Although it’s tempting, refrain from including HTML markup (like <a href="...">, <b> or <p>) in your RSS feed; because you don’t know how it will be presented, doing so can prevent your feed from being displayed correctly. If you need to include a a tag in the text of the feed (e.g., the title of an entry is “Ode to <title>”), make sure you escape ampersands and angle brackets (so that it would be “Ode to <title>”). Another page I visited defined the description tag like this: description - Phrase or sentence describing the channel. But didn't say anything about special formatting. :blush: If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
♥GLWalker Posted March 20, 2008 Author Posted March 20, 2008 Yeah, I kind of thought it may not be possible to place a line break. I can redo somethings and get it to work in the seperate tag, I was just hoping there would be something simpler. Dont know why Im determined to show the freaken keywords, I guess Ive been seeing too many of those tag clouds lately. If I left the keywords hidden as they are in the seperate tag now, viewable only by source, I wonder if that would be cuase for penelization. If its not then I may leave them hidden so that I dont have to see them but the se does. Altho I have read that having keywords on the bottem of the page like crazy could cause penelization too, but its just an rss feed so may not have a bit of revelance. Thanks for the help . Follow the community build: BS3 to osCommerce Responsive from the Get Go! Check out the new construction: Admin Gone to Total BS!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.