News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Board ID in index.template for use of RSS

Started by smartdeviceresource, January 01, 2010, 03:42:08 AM

Previous topic - Next topic

smartdeviceresource

I am trying to add a feed for the current board of which a member is viewing
I feel I've done my due diligence, and have scoured this community and google looking for an answer (this this was difficult as every time a question contained someone's index.template it came up in my search)
I am already aware that a Feed of a board is
http://forum.smartdeviceresource.com/index.php?action=.xml;board=79;type=rss

however to get this to happen in the render of the site's index does not seem to be working

Here is what I currently have (the second one obviously is the board one)

// If RSS feeds are enabled, advertise the presence of one.
   if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged']))
      echo '
   <link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?type=rss;action=.xml" />';
echo '
   <link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="' . $scripturl . '?action=.xml;board=' . $board['id'] . ';type=rss" />';
   


However of every board this results in
http://forum.smartdeviceresource.com/index.php?action=.xml;board=;type=rss

and never id's the board

I have tried a few other methods of identifying the board
$context['current_board']
$board
]href="' . $scripturl . ' "/" . $board['id'] . '?action=.xml;type=rss" />';

and a few more and they have either crashed the page or done the same as listed above, please help, it may just be me of my user who want this but I want this.

Thank You in advance,
and Thank for the help provided so far from my lurking here.
after some thought, i've learned to be humble and leave the answering to the experts, until i too am an expert.  sorry to anyone who I've confused, with my answers

Arantor

Try:

// If RSS feeds are enabled, advertise the presence of one.
   global $board_info;

   if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged']))
      echo '
   <link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?type=rss;action=.xml" />';
echo '
   <link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="' . $scripturl . '?action=.xml;board=' . $board_info['id'] . ';type=rss" />';

smartdeviceresource

after some thought, i've learned to be humble and leave the answering to the experts, until i too am an expert.  sorry to anyone who I've confused, with my answers

Arantor

If you have no further concerns please consider marking this topic solved.

smartdeviceresource

Sorry didn't see solved listed in M.I. Last night (I looked but not hard enough)

Marked Solved now :) thanks again Arantor :)
after some thought, i've learned to be humble and leave the answering to the experts, until i too am an expert.  sorry to anyone who I've confused, with my answers

smartdeviceresource

Hi, I'm reopening this as part of the code that Arantor gave me is throwing a "8: Undefined index:" error for the index 'id'

<link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="' . $scripturl . '?action=.xml;[color=red]board=' . $board_info['id'] .[/color] ';type=rss" />';Am pretty sure it's an easy fix (per my studying of other #8 errors)

I've already turned off template eval
Error is as follows
Quote
Type of error: Undefined 
http://forum.smartdeviceresource.com/index.php?
http://forum.smartdeviceresource.com/Backup/testtheme/css/Themes/core/images/catbg.jpg
8: Undefined index: id
File: {SERVERINFO}/forum/Themes/core/index.template.php
Line: 109 
how/where do I define
$board_info['id']
after some thought, i've learned to be humble and leave the answering to the experts, until i too am an expert.  sorry to anyone who I've confused, with my answers

Arantor

At some point before that in the PHP, ensure that global $board_info; is called.

smartdeviceresource

So would I just
Replace
// The main sub template above the content.
function template_html_above()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;

// Show right to left and the character set for ease of translating.
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '><head>

<meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
<meta name="description" content="', $context['page_title_html_safe'], '" />
<meta name="keywords" content="', $context['meta_keywords'], '" />
<title>', $context['page_title_html_safe'], '</title>';

// Please don't index these Mr Robot.
if (!empty($context['robot_no_index']))
echo '
<meta name="robots" content="noindex" />';

With
// The main sub template above the content.
function template_html_above()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings,$board_info;

// Show right to left and the character set for ease of translating.
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '><head>

<meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
<meta name="description" content="', $context['page_title_html_safe'], '" />
<meta name="keywords" content="', $context['meta_keywords'], '" />
<title>', $context['page_title_html_safe'], '</title>';

// Please don't index these Mr Robot.
if (!empty($context['robot_no_index']))
echo '
<meta name="robots" content="noindex" />';
after some thought, i've learned to be humble and leave the answering to the experts, until i too am an expert.  sorry to anyone who I've confused, with my answers


smartdeviceresource

Just did that still getting the error   :(
// The main sub template above the content.
function template_html_above()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings, $board_info;

// Show right to left and the character set for ease of translating.
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '><head>

<meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
<meta name="description" content="', $context['page_title_html_safe'], '" />
<meta name="keywords" content="', $context['meta_keywords'], '" />
<title>', $context['page_title_html_safe'], '</title>';

// Please don't index these Mr Robot.
if (!empty($context['robot_no_index']))
echo '
<meta name="robots" content="noindex" />';

// Present a canonical url for search engines to prevent duplicate content in their indices.
if (!empty($context['canonical_url']))
echo '
<link rel="canonical" href="', $context['canonical_url'], '" />';

// The ?rc2 part of this link is just here to make sure browsers don't cache it wrongly.
echo '
<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?rc2" />
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/print.css?rc2" media="print" />';

// Show all the relative links, such as help, search, contents, and the like.
echo '
<link rel="help" href="', $scripturl, '?action=help" />
<link rel="search" href="' . $scripturl . '?action=search" />
<link rel="contents" href="', $scripturl, '" />';

// If RSS feeds are enabled, advertise the presence of one.
global $board_info;
if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged']))
echo '
<link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?type=rss;action=.xml" />';
echo '
<link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="' . $scripturl . '?action=.xml;board=' . $board_info['id'] . ';type=rss" />';
after some thought, i've learned to be humble and leave the answering to the experts, until i too am an expert.  sorry to anyone who I've confused, with my answers

smartdeviceresource

#10
So per http://www.simplemachines.org/community/index.php?topic=37644.0

I am also trying with
;board=' . $context['current_board'] . ';type=rss" />'
(which also works)
and now get error
8: Undefined index: current_board

so there is definitly something I'm missing about how to define indexes (either 'ID' or 'current_board')
after some thought, i've learned to be humble and leave the answering to the experts, until i too am an expert.  sorry to anyone who I've confused, with my answers

smartdeviceresource

after some thought, i've learned to be humble and leave the answering to the experts, until i too am an expert.  sorry to anyone who I've confused, with my answers

smartdeviceresource

#12
HAHAHAHA I finally got it to
a) Not have the unknown index error
and
b) show the board RSS only while in a board
and
c)only show the index RSS once

a) and b) Fixed with this code
// If RSS feeds are enabled, advertise the presence of one.
if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged']))
echo '
<link rel="alternate" type="application/rss+xml" title="Recent Topics" href="', $scripturl, '?type=rss;action=.xml" />';

  // If we're viewing a topic, these should be the previous and next topics, respectively.
if (!empty($context['current_topic']))
echo '
<link rel="prev" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=prev" />
<link rel="next" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=next" />';

// If we're in a board, or a topic for that matter, the index will be the board's index.
if (!empty($context['current_board']))
echo '
<link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0" />
<link rel="alternate" type="application/rss+xml" title=" ', $txt['rss'], ' for Board ', $context['current_board'], '" href="' . $scripturl . '?board=' . $context['current_board'] . ';action=.xml;type=rss" />';

the Last line there in //if we're in a board, or a topic is what I changed/added

c) fixed by
in index.template
Replace
'<li><a id="button_rss" href="' . $scripturl . '?action=.xml;type=rss" class="new_win"><span>' . $txt['rss'] . '</span></a></li>' : '', '
so that it matches the RSS call in the Header
'<li><a id="button_rss" href="' . $scripturl . '?type=rss;action=.xml" class="new_win"><span>' . $txt['rss'] . '</span></a></li>' : '', '
after some thought, i've learned to be humble and leave the answering to the experts, until i too am an expert.  sorry to anyone who I've confused, with my answers

Advertisement: