To use this website completely, it is necessary to store cookies on your computer.
 

* Navigator

Expand - Collapse

* Statistic


  • *Total Posts: 16431
  • *Total Topics: 2522
  • *Online Today: 10
  • *Most Online: 292
(12. Nov 2016, 09:37:31)
  • *Users: 0
  • *Guests: 0
  • *Spiders: 1
  • *Total: 1

  • *MSN (Media)

* Calendar

Mo
Tu
We
Th
Fr
Sa
Su
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

Sitemap extension for Portamx

Started by Fisch.666, 15. Jan 2012, 15:52:40

previous topic - next topic

0 Members and 0 Guests are viewing this topic.

Fisch.666

15. Jan 2012, 15:52:40 Last Edit: 04. Jul 2012, 15:28:27 by Fisch.666
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]

feline

#1
16. Jan 2012, 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.

Fisch.666

#2
16. Jan 2012, 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.  :)

feline

#3
16. Jan 2012, 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.

Fisch.666

#4
17. Jan 2012, 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.

feline

#5
19. Jan 2012, 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.

Fisch.666

#6
19. Jan 2012, 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:

Quote from: feline on 19. Jan 2012, 10:37:01
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)?

feline

#7
19. Jan 2012, 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.

Fisch.666

#8
19. Jan 2012, 12:10:04
Hey, thanks again for this info. I've just updated my first post with the new version.

feline

#9
20. Jan 2012, 14:20:52
Quote from: Fisch.666 on 15. Jan 2012, 15:52:40
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.

feline

#10
20. Jan 2012, 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.

Fisch.666

#11
28. Jan 2012, 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.

Fisch.666

#12
04. Jul 2012, 15:26:18
Hi,

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

Fisch.666

#13
08. Dec 2014, 07:30:15
Quote from: Fisch.666 on 15. Jan 2012, 15:52:40
[attachment deleted by admin]


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