TinyPortal

Development => Support => Topic started by: bentong on October 17, 2007, 04:05:32 AM

Title: Insert code in index and articles
Post by: bentong on October 17, 2007, 04:05:32 AM
hello, ive installed this social bookmarks mod(http://custom.simplemachines.org/mods/index.php?mod=967 (http://custom.simplemachines.org/mods/index.php?mod=967)) in to my forum and it works but now iam planning to put this social bookmarks in the index and article section in tinyportal(same spot where it is shown in the forum which is below the navigation link [Site Title > Category > Article Title]. may i know what tinyportal file should i insert the code?
iam using smf 1.1.4 and tinyportal 0.9.8
thanks.
Title: Re: Insert code in index and articles
Post by: IchBin on October 17, 2007, 05:27:20 PM
I think you're looking for TPortal.template.php judging by your description.
Title: Re: Insert code in index and articles
Post by: bentong on October 18, 2007, 05:21:11 AM
thanks i have now successfully inserted the code into the TPortal.template.php (bookmark icons is there but the page url and title is wrong bec its only for the topic forum and iam using it in article.)
but i have some prob, i cant get the page url and the title page.
sample link
http://del.icio.us/post?url=http%3A%2F%2Fmysite.com%2Findex.php%3Ftopic%3D.0&title=

heres the code
// START OF SOCIAL BOOKMARKS
if($modSettings['socialbookmarks']) {
$socialbookmark = array();
// DEFAULT MOST POPULAR BOOKMARKING SITES
$socialbookmark[] = array('name' => 'Del.icio.us', 'icon' => 'delicious', 'url' => 'http://del.icio.us/post?url=$1&title=$2');
$socialbookmark[] = array('name' => 'Digg', 'icon' => 'digg', 'url' => '>http://www.digg.com/submit?phase=2&url=$1&title=$2');
$socialbookmark[] = array('name' => 'FURL', 'icon' => 'furl', 'url' => 'http://www.furl.net/storeIt.jsp?t=$2&u=$1');
$socialbookmark[] = array('name' => 'FaceBook', 'icon' => 'facebook', 'url' => 'http://www.facebook.com/share.php?u=$1');
$socialbookmark[] = array('name' => 'Stumble Upon', 'icon' => 'stumbleupon', 'url' => 'http://www.stumbleupon.com/submit?url=$1&title=$2');
$socialbookmark[] = array('name' => 'Reddit', 'icon' => 'reddit', 'url' => 'http://reddit.com/submit?url=$1&title=$2');
$socialbookmark[] = array('name' => 'SlashDot', 'icon' => 'slashdot', 'url' => 'http://slashdot.org/bookmark.pl?title=$2&url=$1');
// UNLOCK EXTRA BOOKMARK SITES
// or ADD YOUR OWN (use $1 for the url, $2 for the topic subject)
// Remove the // before any of the lines to unlock any bookmarking sites listed below
$socialbookmark[] = array('name' => 'Ask', 'icon' => 'ask', 'url' => 'http://mystuff.ask.com/mysearch/QuickWebSave?v=2.0&t=webpages&title=$2&url=$1');
$socialbookmark[] = array('name' => 'BlinkBits', 'icon' => 'blinkbits', 'url' => 'http://blinkbits.com/bookmarklets/save.php?v=1&source_url=$1&title=$2');
$socialbookmark[] = array('name' => 'BlinkList', 'icon' => 'blinklist', 'url' => 'http://blinklist.com/index.php?Action=Blink/addblink.php&Name=$2&Description=$2&Url=$1');
$socialbookmark[] = array('name' => 'Co.mments', 'icon' => 'comments', 'url' => 'http://co.mments.com/track?url=$1&title=$2');
$socialbookmark[] = array('name' => 'Delirious', 'icon' => 'delirious', 'url' => 'http://de.lirio.us/rubric/post?uri=$1');
$socialbookmark[] = array('name' => 'Feed Me Links', 'icon' => 'feedmelinks', 'url' => 'http://feedmelinks.com/categorize?from=toolbar&op=submit&name=$2&url=$1&version=0.7');
$socialbookmark[] = array('name' => 'Google Bookmarks', 'icon' => 'googlebookmarks', 'url' => 'http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk=$1&title=$2');
$socialbookmark[] = array('name' => 'Linkagogo', 'icon' => 'linkagogo', 'url' => 'http://www.linkagogo.com/go/AddNoPopup?url=$1&title=$2');
$socialbookmark[] = array('name' => 'Ma.gnolia', 'icon' => 'magnolia', 'url' => 'http://ma.gnolia.com/bookmarklet/add?url=$1&title=$2&description=$2');
$socialbookmark[] = array('name' => 'MSN Live', 'icon' => 'msnlive', 'url' => 'https://favorites.live.com/quickadd.aspx?url=$1&title$2');
$socialbookmark[] = array('name' => 'Netscape', 'icon' => 'netscape', 'url' => 'http://www.netscape.com/submit/?U=$1&T=$2');
$socialbookmark[] = array('name' => 'Netvouz', 'icon' => 'netvouz', 'url' => 'http://netvouz.com/action/submitBookmark?url=$1&title=$2&popup=no');
$socialbookmark[] = array('name' => 'Newsvine', 'icon' => 'newsvine', 'url' => 'http://www.newsvine.com/_wine/save?u=$1&h=$2');
$socialbookmark[] = array('name' => 'RawSugar', 'icon' => 'rawsugar', 'url' => 'http://www.rawsugar.com/tagger/?turl=$1&tttl=$2');
$socialbookmark[] = array('name' => 'Rojo', 'icon' => 'rojo', 'url' => 'http://www.rojo.com/add-subscription/?resource=$1');
$socialbookmark[] = array('name' => 'Smarking', 'icon' => 'smarking', 'url' => 'http://smarking.com/editbookmark/?url=$1&title=$2');
$socialbookmark[] = array('name' => 'Socializer', 'icon' => 'socializer', 'url' => 'http://ekstreme.com/socializer/?url=$1&title=$2');
$socialbookmark[] = array('name' => 'Sphinn', 'icon' => 'sphinn', 'url' => 'http://sphinn.com/submit.php?url=$1&title=$2');
$socialbookmark[] = array('name' => 'Spurl', 'icon' => 'spurl', 'url' => 'http://www.spurl.net/spurl.php?url=$1&title=$2&v=3&blocked=$2');
$socialbookmark[] = array('name' => 'Squidoo', 'icon' => 'squidoo', 'url' => 'http://www.squidoo.com/lensmaster/bookmark?$1');
$socialbookmark[] = array('name' => 'Tailrank', 'icon' => 'tailrank', 'url' => 'http://tailrank.com/share/?title=$2&link_href=$1');
$socialbookmark[] = array('name' => 'Technorati', 'icon' => 'technorati', 'url' => 'http://www.technorati.com/faves?add=$1');
$socialbookmark[] = array('name' => 'Yahoo My Web', 'icon' => 'yahoomyweb', 'url' => 'http://myweb2.search.yahoo.com/myresults/bookmarklet?u=$1&t=$2');

// CREATE URL/TITLE & URLENCODE
$url = urlencode($scripturl . '?topic=' . $topic . '.0');
$title = urlencode($topicinfo['subject']);

// REPLACE $1 AND $2 WITH THE URL AND TITLE
foreach($socialbookmark as $a => $b) {
$b['url'] = str_replace('$1', $url, $b['url']);
$socialbookmark[$a]['url'] = str_replace('$2', $title, $b['url']);
}
// TIDY UP
unset($a,$b);
}

// PASS THE VARIABLE TO THE THEME
$context['socialbookmarks'] = $socialbookmark;

    // SOCIAL BOOKMARK BOX
if($modSettings['socialbookmarks']) {
echo '<div style="width:320px;padding:2px;float:right;text-align:right;" class="socialbookmark">';
foreach($context['socialbookmarks'] as $a => $b) {
echo '<a href="'.$b['url'].'" title="'.$b['name'].'" target="_blank">
<img src="'.$settings['default_images_url'].'/socialbookmarks/'.$b['icon'].'.png" title="'.$b['name'].'" alt="'.$b['name'].'"></a> ';
}
echo '</div><br />';
}
// END SOCIAL BOOKMARK BOX



    // END OF SOCIAL BOOKMARKS



i think my problem is here
// CREATE URL/TITLE & URLENCODE
     
$url = urlencode($scripturl . '?topic=' . $topic . '.0');
$title = urlencode($topicinfo['subject']);

// REPLACE $1 AND $2 WITH THE URL AND TITLE
foreach($socialbookmark as $a => $b) {
$b['url'] = str_replace('$1', $url, $b['url']);
$socialbookmark[$a]['url'] = str_replace('$2', $title, $b['url']);
}
// TIDY UP
unset($a,$b);
}


can someone pls help me iam really new to php and dont know how to code it safely.
thanks.
Title: Re: Insert code in index and articles
Post by: IchBin on October 18, 2007, 02:28:27 PM
Can I see this on your site so I can see the output and what its supposed to do?
Title: Re: Insert code in index and articles
Post by: bentong on October 19, 2007, 03:44:07 AM
the site is still on my computer i havent published it yet.
here are some links i have

index.php (http://mysite.com)
http://del.icio.us/post?url=http://mysite.com/index.php?topic=.0&title=

category page (http://mysite.com/index.php?cat=2)
http://del.icio.us/post?url=http://mysite.com/index.php?topic=.0&title=

article page  (http://mysite.com/index.php?page=3)
http://del.icio.us/post?url=http://mysite.com/index.php?topic=.0&title=

thanks
Title: Re: Insert code in index and articles
Post by: IchBin on October 19, 2007, 11:57:33 PM
Sorry, I'm a little confused here. Do you just need it replace the topic link with the page of the article link instead? Don't even know what social bookmarks are here. lol
Title: Re: Insert code in index and articles
Post by: bentong on October 20, 2007, 02:36:53 AM
oh iam sorry if i didnt explain it well.
yes i need the url and topic to be change so it will correctly display the url and title of the article.
heres the mod link http://custom.simplemachines.org/mods/index.php?mod=967

example, this is a working link in the forum topic
http://del.icio.us/post?url=http://mysite.com/index.php?topic=1.0&title=my title

bec i dont know how tinyportal works i dont know how to edit the code that generates the link for the del.icio.us.

this is the code that generates links
// CREATE URL/TITLE & URLENCODE
     
$url = urlencode($scripturl . '?topic=' . $topic . '.0');
$title = urlencode($topicinfo['subject']);

// REPLACE $1 AND $2 WITH THE URL AND TITLE
foreach($socialbookmark as $a => $b) {
$b['url'] = str_replace('$1', $url, $b['url']);
$socialbookmark[$a]['url'] = str_replace('$2', $title, $b['url']);
}
// TIDY UP
unset($a,$b);
}


can someone pls edit the code above so it will give me the correct url and topic of an article?

heres the link for the index.php (http://mysite.com)
http://del.icio.us/post?url=http://mysite.com/index.php?topic=.0&title=

wherein it is supposed to be
http://del.icio.us/post?url=http://mysite.com/index.php&title=My Site Title

heres the link for an article (http://mysite.com/index.php?cat=5)
http://del.icio.us/post?url=http://mysite.com/index.php?topic=.0&title=

wherein it is supposed to be
http://del.icio.us/post?url=http://mysite.com/index.php?cat=5&title=My Article Title
Title: Re: Insert code in index and articles
Post by: IchBin on October 20, 2007, 04:08:38 AM
Well, I still don't quite get it, but I'm guessing you just need to change this one line that sets the link.

$url = urlencode($scripturl . '?topic=' . $topic . '.0');

To something like this to pick up the article that you are in. Of course, this is all based on whether I understand what you need. lol
$url = urlencode($scripturl . '?page=' . $_GET['page']);
Title: Re: Insert code in index and articles
Post by: bentong on October 21, 2007, 03:12:45 AM
thanks but it gets the value of the page only and no title.
it should digg in the database right?

heres the sample working link(with your code)
http://del.icio.us/post?url=http%3A%2F%2Fmysite.com%2Findex.php%3Fpage%3D11&title=

if iam in a category "cat" it cant get the "cat" number.
or even if iam in the index.php bec "page" and "cat" does not exist.


i think it should have been something like this

if cat exists
$url = urlencode($scripturl . '?cat=' . $_GET['cat']);
if page exists
$url = urlencode($scripturl . '?page=' . $_GET['page']);
else (meaning the index.php only)
$url = urlencode($scripturl);

i dont know how to do it in nested if.
and i also dont know if it is the fastest and safest way to do it.
thanks again
Title: Re: Insert code in index and articles
Post by: bentong on October 21, 2007, 03:52:35 AM
ive already fixed the title problem.

my code is not working
            if ($_GET['page'] == "") {
            $url = urlencode($scripturl . '?page=' . $_GET['page']);
            }
            elseif ($_GET['cat'] == "") {
            $url = urlencode($scripturl . '?cat=' . $_GET['cat']);
      }
      else {
            $url = urlencode($scripturl);
      }
Title: Re: Insert code in index and articles
Post by: bentong on October 21, 2007, 04:23:50 AM
oks ive fixed it already
thanks for the help.
Title: Re: Insert code in index and articles
Post by: IchBin on October 21, 2007, 05:09:04 AM
Well, I didn't quite get what this bookmark stuff is all about, but glad I could help you on your way. lol