Language: 
To browser these website, it's necessary to store cookies on your computer.
The cookies contain no personal information, they are required for program control.
  the storage of cookies while browsing this website, on Login and Register.

User

Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Select language:

Community



Stats


  • *Total Posts: 16389
  • *Total Topics: 2501
  • *Online Today: 14
  • *Most Online: 292
(12.11.16, 09:37:31)
  • *Users: 0
  • *Guests: 0
  • *Spiders: 4
  • *Total: 4

  • *Google
  • *Baidu (3)

Author Topic: Sitemap extension for Portamx  (Read 19966 times)

0 Members and 0 Guests are viewing this topic.

Offline Fisch.666

  • Jr. Member
  • **
  • Posts: 56
Sitemap extension for Portamx
« on: 15.01.12, 15:52:40 »
Hi!

To add portamx single pages and articles to the Sitemap (http://custom.simplemachines.org/mods/index.php?mod=755) mod i've created an extension for the sitemap addon. I've added this extension as an attachment to this post.

Please Note
---------------
I have only very basic knowledge of php and smf so use this extension at your own risk. Maybe a more experienced user can have a look at this extension.

Please Note for PortaMx versions prior 1.5
---------------
For the singlepages in the .xml sitemap priority is statically set to 1.0 and lastchange to the current timestamp (with time())
because we have no create date for the single page.

[attachment deleted by admin]

Offline feline

  • CO PortaMx corp.
  • Administrator
  • *
  • Posts: 5779
  • Gender: Female
Re: Sitemap extension for Portamx
« Reply #1 on: 16.01.12, 15:37:34 »
Well .. I find only one file named "dummy" in the archive  :o seems like that is not correct  ;)
Same on SMF forum ...
Many are stubborn in relation to the path, a few in relation to the target.

Offline Fisch.666

  • Jr. Member
  • **
  • Posts: 56
Re: Sitemap extension for Portamx
« Reply #2 on: 16.01.12, 16:26:11 »
Hi Feline,

do you have removed the .zip ending from the filename? As i wrote above, the forums here doesn't allow .tar.gz files as an attachment, thats the reason why i have added the .zip ending to the file.  :)

Offline feline

  • CO PortaMx corp.
  • Administrator
  • *
  • Posts: 5779
  • Gender: Female
Re: Sitemap extension for Portamx
« Reply #3 on: 16.01.12, 23:28:42 »
of course .. but a good tool can extract any file  ;)
Look at your attached archive here and on SMF .. both are same buggy...
Many are stubborn in relation to the path, a few in relation to the target.

Offline Fisch.666

  • Jr. Member
  • **
  • Posts: 56
Re: Sitemap extension for Portamx
« Reply #4 on: 17.01.12, 00:49:25 »
Mhhh, very strange. Thats a normal "tar.gz" file from an linux system which extracts on linux without a problem. Only windows programs (i've tested 2 of them) get this "dummy" file. Anyway, i've attached a new file as a .zip archive to the first post.

Offline feline

  • CO PortaMx corp.
  • Administrator
  • *
  • Posts: 5779
  • Gender: Female
Re: Sitemap extension for Portamx
« Reply #5 on: 19.01.12, 10:37:01 »
Well .. your small mod worked, but I found smaller problems and bugs ...
1.. you can use the forum default language for the titles, this is stored in the variable $language
2.. for Single pages you have to check, if the page enabled.
3.. for articles you have to check, if the article enabled and approved
4.. for pages and articles you have to check, if a user can see the page/article (for xml must have guest access)

Fix for all points:
In sitemap_spages.php the function list_getSpages:
Code: [Select]
function list_getSpages($start, $items_per_page, $sort)
{
global $smcFunc, $language;

$request = $smcFunc['db_query']('','
SELECT id, side, config, acsgrp
FROM {db_prefix}portamx_blocks
WHERE side = "pages" AND active > 0
ORDER BY {raw:sort}',
array(
'sort' => $sort == '1=1' ? 'id DESC' : $sort,
)
);

$spages = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if(allowPmxGroup($row['acsgrp']))
{
$cfg = unserialize($row['config']);
$row['title'] = $cfg['title'][$language];
$row['name'] = $cfg['pagename'];
$spages[] = $row;
}
}
$smcFunc['db_free_result']($request);

return $spages;
}

In sitemap_articles.php the function list_getArticles:
Code: [Select]
function list_getArticles($start, $items_per_page, $sort)
{
global $smcFunc, $language;

$request = $smcFunc['db_query']('','
SELECT a.config, a.name, a.id, a.created, a.acsgrp, mem.real_name, mem.id_member
FROM {db_prefix}portamx_articles as a
LEFT JOIN {db_prefix}members as mem ON (mem.id_member = a.owner)
WHERE a.active > 0 AND a.approved > 0
ORDER BY {raw:sort}',
array(
'sort' => $sort == '1=1' ? 'a.id DESC' : $sort,
)
);

$articles = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if(allowPmxGroup($row['acsgrp']))
{
$cfg = unserialize($row['config']);
$row['title'] = $cfg['title'][$language];
$articles[] = $row;
}
}
$smcFunc['db_free_result']($request);

return $articles;
}

Now it works as well ...  ;)
I attached the both files here...

[attachment deleted by admin]
Many are stubborn in relation to the path, a few in relation to the target.

Offline Fisch.666

  • Jr. Member
  • **
  • Posts: 56
Re: Sitemap extension for Portamx
« Reply #6 on: 19.01.12, 11:01:40 »
Wow great, thanks for this fixes. O0 I didn't think of the access and approved/enabled levels in Portamx.  :-[

Only one question before i update the package:

1.. you can use the forum default language for the titles, this is stored in the variable $language

What happens if the forum default language is e.g. german-utf8 and the title is only written in english (The title for german-utf8 should be empty)?

Offline feline

  • CO PortaMx corp.
  • Administrator
  • *
  • Posts: 5779
  • Gender: Female
Re: Sitemap extension for Portamx
« Reply #7 on: 19.01.12, 11:31:28 »
Well .. in this case the title is empty. But .. you can use follow:

replace:
Code: [Select]
$row['title'] = $cfg['title'][$language];

with:
Code: [Select]
$row['title'] = !empty($cfg['title'][$language]) ? $cfg['title'][$language] : $cfg['title']['english'];

in both files. Now if the $language title empty, the english is used ...
Many are stubborn in relation to the path, a few in relation to the target.

Offline Fisch.666

  • Jr. Member
  • **
  • Posts: 56
Re: Sitemap extension for Portamx
« Reply #8 on: 19.01.12, 12:10:04 »
Hey, thanks again for this info. I've just updated my first post with the new version.

Offline feline

  • CO PortaMx corp.
  • Administrator
  • *
  • Posts: 5779
  • Gender: Female
Re: Sitemap extension for Portamx
« Reply #9 on: 20.01.12, 14:20:52 »
For singlepages in the .xml sitemap priority is statically set to 1.0 and lastchange to the current timestamp (with time()) because we have no create date for the single page.
Well .. for the next PortaMx release (1.50) we added a "created" element to the config array, this hold the time of the last block save time. This can used for xml.
It's only a small change on the file sitemap_spages.php
Find:
Code: [Select]
function SpagesXML()
{
global $modSettings, $scripturl;

// Get our information from the database
if (($spages = cache_get_data('xml_spages', $modSettings['sitemap_cache_ttl'])) == null)
{
$temp_spages = list_getSpages(0, 0, 'id DESC');
// And assign it to an array
$spages = array();
foreach ($temp_spages as $row)
{
$spages[] = array(
'url' => fix_possible_url($scripturl . '?spage=' . $row['name']),
'time' => date_iso8601(time()),
'priority' => '1.0',
);
}
cache_put_data('xml_spages', $spages, $modSettings['sitemap_cache_ttl']);
}

return $spages;
}

Replace with:
Code: [Select]
function SpagesXML()
{
global $modSettings, $scripturl;

// Get our information from the database
if (($spages = cache_get_data('xml_spages', $modSettings['sitemap_cache_ttl'])) == null)
{
$temp_spages = list_getSpages(0, 0, 'id DESC');
// And assign it to an array
$spages = array();
foreach ($temp_spages as $row)
{
$spages[] = array(
'url' => fix_possible_url($scripturl . '?spage=' . $row['name']),
'time' => date_iso8601($row['created']),
'priority' => priority($row['created']),
);
}
cache_put_data('xml_spages', $spages, $modSettings['sitemap_cache_ttl']);
}

return $spages;
}

Find:
Code: [Select]
function list_getSpages($start, $items_per_page, $sort)
{
global $smcFunc, $language;

$request = $smcFunc['db_query']('','
SELECT id, side, config, acsgrp
FROM {db_prefix}portamx_blocks
WHERE side = "pages" AND active > 0
ORDER BY {raw:sort}',
array(
'sort' => $sort == '1=1' ? 'id DESC' : $sort,
)
);

$spages = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if(allowPmxGroup($row['acsgrp']))
{
$cfg = unserialize($row['config']);
$row['title'] = $cfg['title'][$language];
$row['name'] = $cfg['pagename'];
$spages[] = $row;
}
}
$smcFunc['db_free_result']($request);

return $spages;
}

Replace with:
Code: [Select]
function list_getSpages($start, $items_per_page, $sort)
{
global $smcFunc, $language;

$request = $smcFunc['db_query']('','
SELECT id, side, config, acsgrp
FROM {db_prefix}portamx_blocks
WHERE side = "pages" AND active > 0
ORDER BY {raw:sort}',
array(
'sort' => $sort == '1=1' ? 'id DESC' : $sort,
)
);

$spages = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if(allowPmxGroup($row['acsgrp']))
{
$cfg = unserialize($row['config']);
$row['title'] = !empty($cfg['title'][$language]) ? $cfg['title'][$language] : $cfg['title']['english'];
$row['name'] = $cfg['pagename'];
$row['created'] = !empty($cfg['created']) ? $cfg['created'] : time();
$spages[] = $row;
}
}
$smcFunc['db_free_result']($request);

return $spages;
}

Then .. up from the next release the time/priority is show correct  ;)
Many are stubborn in relation to the path, a few in relation to the target.

Offline feline

  • CO PortaMx corp.
  • Administrator
  • *
  • Posts: 5779
  • Gender: Female
Re: Sitemap extension for Portamx
« Reply #10 on: 20.01.12, 22:19:51 »
and more for the next release about your sitemap extension ...
we added a checkbox for all block (only on single pages) and for articles to enable/disable to show the block in sitemaps.
this settings is stored in the config array as "show_sitemap" and is not empty on show.
Then can to check pages/articles:
a) without access checking:
Code: [Select]
if(!empty($cfg['show_sitemap']))
or
b) with access checking:
Code: [Select]
if(!empty($cfg['show_sitemap']) && allowPmxGroup($row['acsgrp']))
I prefer the second methode ... if a guest have no access, he becomes a error massage (no access) and can register  ;)
Many are stubborn in relation to the path, a few in relation to the target.

Offline Fisch.666

  • Jr. Member
  • **
  • Posts: 56
Re: Sitemap extension for Portamx
« Reply #11 on: 28.01.12, 16:00:31 »
Hi!

Thanks for this info. Atm i'm quite busy because i'm doing my exams. But i will have a look at this after the exams and the release of portamx 1.50.

Offline Fisch.666

  • Jr. Member
  • **
  • Posts: 56
Re: Sitemap extension for Portamx
« Reply #12 on: 04.07.12, 15:26:18 »
Hi,

i've just updated my first post with the changes needed for PortaMx 1.5.

Offline Fisch.666

  • Jr. Member
  • **
  • Posts: 56
Re: Sitemap extension for Portamx
« Reply #13 on: 08.12.14, 07:30:15 »
[attachment deleted by admin]

Mhhh, any reasons why the attachment was deleted? Still works here with Portamx 1.53.