Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Pages: [1] 2 3 4

Author Topic: Internal links  (Read 24612 times)

mattonik

  • Full Member
  • ***
  • Karma: 7
  • Posts: 123
    • http://www.mattonik.sk
Internal links
« on: April 09, 2007, 08:05:55 PM »

!!Important: edit *!
!edit: js function has gone trough some changes!


//Autor: mattonik
//url: www.mattonik.sk
//mail: mattonik@gmail.com

This is an piece of code that will expand your administration area (Articles, Extra Content and Sites administration) with list of already created articles, sites and categories, which you can easily insert into your text by just clicking on them as inserting normal link :)
JS function identifies if some text is selected or not, if not, the title of the link is inserted as a linking text.
Hope it's clear, for additional info or bug report, use my mail or icq (193-025-422) or this forum.
It's my first mod so i hope it will be useful. Any help pr improvments are welcome.
Thanks, mattonik

example: http://snews.mattonik.sk/
user: test
pass: test

!*edit!:
i forgot to call the function in admin area so here is themissing part:

on line 1255 where "echo '</p>'; is, after this add:
InterneLinky();

u can find better explanation here: http://www.solucija.com/forum/viewtopic.php?pid=27493#p27493


##############################################
#php function:                               #
##############################################

There's no special place where to place this, but i have putted it just after Menu Articles function which starts somewehere about line 785:

!IMPORTANT:Function is not creating absolute links, if you want so, change this:
<a href="javascript:tag1(\'vlozLink\',\''.$categorySEF.'/'.$r["seftitle"].'\',\''.$r["title"].'\')" title="'.$r['title'].'">'.$r['title'].'</a>

into this:
<a href="javascript:tag1(\'vlozLink\',\''.db("website").$categorySEF.'/'.$r["seftitle"].'\',\''.$r["title"].'\')" title="'.$r['title'].'">'.$r['title'].'</a>
Code: [Select]
<?php

function InterneLinky() {
echo '<p><a title="'.l('InterneLinky').'" onclick="toggle(\'InterneLinky\')" style="cursor: pointer;">'.l('InterneLinky').'</a>';
echo '<div id="InterneLinky" style="display: none;">';
echo '<div id="ILclanky"><strong>'.l('ILclanky').'</strong><ul>';
$query "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published = 1 ORDER BY date DESC";
$result mysql_query($query);
$home s('home_sef');

while ($r mysql_fetch_array($result)) {
$date date(s('date_format'), strtotime($r['date']));
$categorySEF find_cat_sef($r['category']);
$title $r['category'] == $home retrieve('name''categories''seftitle'$categorySEF);

echo '<li><a href="javascript:tag1(\'vlozLink\',\''.$categorySEF.'/'.$r["seftitle"].'\',\''.$r["title"].'\')" title="'.$r['title'].'">'.$r['title'].'</a></li>';
    }
  echo 
'</ul></div>';
  
  echo 
'<div id="ILsites"><strong>'.l('ILsites').'</strong><ul>';  
  
$query "SELECT * FROM ".db('prefix')."articles WHERE position = 3 AND published = 1 ORDER BY date DESC";
$result mysql_query($query);
while ($r mysql_fetch_array($result)) {
$date date(s('date_format'), strtotime($r['date']));
$categorySEF find_cat_sef($r['category']);
$title $r['category'] == $home retrieve('name''categories''seftitle'$categorySEF);

echo '<li><a href="javascript:tag1(\'vlozLink\',\''.$categorySEF.'/'.$r["seftitle"].'\',\''.$r["title"].'\')" title="'.$r['title'].'">'.$r['title'].'</a></li>';
    }
    
   echo 
'</ul></div>';
   
     echo 
'<div id="ILcat"><strong>'.l('ILcat').'</strong><ul>';  
  
$query "SELECT name,seftitle FROM ".db('prefix')."categories WHERE published = 'YES'";
$result mysql_query($query);
while ($r mysql_fetch_array($result)) {
echo '<li><a href="javascript:tag1(\'vlozLink\',\''.$r["seftitle"].'\',\''.$r["name"].'\')" title="'.$r['name'].'">'.$r['name'].'</a></li>';
    }
    
   echo 
'</ul></div>';
  echo 
'</div></p>';
}

?>
################################################
#JS functions                                  #
################################################

After the   "basic html textarea editor" insert:
Code: [Select]
function tag1(tag1,$link,$title) {
    var src = document.getElementById("txt");
    if(tag1 == 'vlozLink'){
        var url = $link;
    var title = $title;
if(url != null) { start = "<a href=\""+url+"\" title=\""+title+"\">"; end = "<\/a>"; } else { start = ""; end = "";                        }
  }
  else { var start = "<" + tag + ">"; var end = "</" + tag + ">"; }
if(!src.setSelectionRange) {
var selected = document.selection.createRange().text;
if(selected.length <= 0) { src.value += start + title + end;
        } else {
            var codetext = start + selected + end;
            document.selection.createRange().text = codetext;
        }
} else {
        var pretext = src.value.substring(0, src.selectionStart);
        var codetext = start + src.value.substring(src.selectionStart, src.selectionEnd) + end;
        var posttext = src.value.substring(src.selectionEnd, src.value.length)
        if(codetext == start + end)
            codetext = start + title + end;
            src.value = pretext + codetext + posttext;
    }
src.focus();
}
################################################
#Css style                                     #
################################################

In your CSS file you can paste this:
Code: [Select]
#InterneLinky {
padding: 0.3em;
border: 1px solid #ccc;
}

#ILclanky {
display: block;
width: 20em;
height: 20em;
overflow:auto;
float: left;
}

#ILsites {
display: block;
width: 40%;
height: 20em;
overflow:auto;
padding-left: 0.3em;
float: left;
border-left: 1px solid #ccc;
}

#ILcat {
display: block;
width: 20%;
height: 20em;
overflow:auto;
padding-left: 0.3em;
border-left: 1px solid #ccc;
}
but you can modify it as u like, but #InterneLinky is the div id ;)      

###############################################
# Language variables                          #
###############################################

Just put this somewhere in language definition
Code: [Select]
#InterneLinky
$l['InterneLinky'] = 'Internal Links';
$l['ILclanky'] = 'Articles';
$l['ILcat'] = 'Categories';
$l['ILsites'] = 'Pages';
Slovak translation:
 
Code: [Select]
#InterneLinky
$l['InterneLinky'] = 'Interné odkazy';
$l['ILclanky'] = 'Články';
$l['ILcat'] = 'Kategórie';
$l['ILsites'] = 'Stránky';
« Last Edit: March 22, 2008, 01:04:41 AM by Keyrocks »
Logged

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
Internal links
« Reply #1 on: April 10, 2007, 01:35:49 AM »

These seems very promising - do you have a demo example available?
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

mattonik

  • Full Member
  • ***
  • Karma: 7
  • Posts: 123
    • http://www.mattonik.sk
Internal links
« Reply #2 on: April 10, 2007, 09:57:09 AM »

thanks man. not now, working on it (some problem with .htaccess)
Logged

mattonik

  • Full Member
  • ***
  • Karma: 7
  • Posts: 123
    • http://www.mattonik.sk
Internal links
« Reply #3 on: April 10, 2007, 03:11:45 PM »

I forgot something in instructions so in edit you can find it now. and i've setup example site on http://snews.mattonik.sk, user: test, pass: test

hope u like it
Logged

mattonik

  • Full Member
  • ***
  • Karma: 7
  • Posts: 123
    • http://www.mattonik.sk
Internal links
« Reply #4 on: April 10, 2007, 03:42:46 PM »

Thanks a lot. If you have any suggestions how to improve it, i would like to know.
And sorry for my english
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Internal links
« Reply #5 on: April 10, 2007, 03:45:22 PM »

Very useful, mattonik. Thanks for sharing!
Logged

David

  • Hero Member
  • *****
  • Karma: 7
  • Posts: 567
Internal links
« Reply #6 on: April 10, 2007, 03:58:00 PM »

Great mod! thanks mattonik!
Logged

mattonik

  • Full Member
  • ***
  • Karma: 7
  • Posts: 123
    • http://www.mattonik.sk
Internal links
« Reply #7 on: April 10, 2007, 04:43:40 PM »

Quote from: bakercad
A question:  Where would the "Sites" list come from?

Suggestion:  Add "Pages" to the list.
:D:D my fault, "Sites" are "Pages". thanks for bug reporting :-)
Logged

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • “I'm a self-made man and worships my creator.”
    • p-ahlqvist.com
Internal links
« Reply #8 on: April 10, 2007, 05:27:37 PM »

Freaking cool, mattonik... Awsome work. Like it a lotsie...
Logged
"It's only dead fish that goes with the flow... "
Updated

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Internal links
« Reply #9 on: April 10, 2007, 05:39:09 PM »

Quote from: Patric
Freaking cool, mattonik... Awsome work. Like it a lotsie...
OK - maybe I am missing the point since I really don't understand (from the initial description) what the purpose of this mod is. Patric... why is it "awsome..." and why do you "Like it a lotsie..." give me your "testimonial" P-man! :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Internal links
« Reply #10 on: April 10, 2007, 06:16:48 PM »

Anything that allows to select Articles and Pages for putting link to them in text of new article is great :D

I really hate trying to remember and typing those SEF titles  :mad:
Logged

mattonik

  • Full Member
  • ***
  • Karma: 7
  • Posts: 123
    • http://www.mattonik.sk
Internal links
« Reply #11 on: April 10, 2007, 06:30:57 PM »

Quote from: codetwist
Anything that allows to select Articles and Pages for putting link to them in text of new article is great :D

I really hate trying to remember and typing those SEF titles  :mad:
my words :D that's why i've created this mod

@bakercad: nice explanation with screenshots :)
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Internal links
« Reply #12 on: April 10, 2007, 07:39:21 PM »

@Bakercad - excellent explanation with the screenshots.
@Mattonik - Indeed, this does seem to be a very useful mod.
Eliminates viewing, copying and pasting links from the browser. Top Notch!  I'll have to try this out now. :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

mattonik

  • Full Member
  • ***
  • Karma: 7
  • Posts: 123
    • http://www.mattonik.sk
Internal links
« Reply #13 on: April 10, 2007, 07:46:03 PM »

@keyrocks - i'm glad you like it in the end :) hope it will be useful
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Internal links
« Reply #14 on: April 10, 2007, 08:17:19 PM »

@Mattonik - just trying to install this mod now.
Question - where is this located? Could you provide a few lines of code around it?
Quote
"I forgot to call the function in admin area so here is the missing part:
on line 1255 where "echo '

'; is, after this add:
     InterneLinky();
Line locations are not always a good way to reference a location. For instance, line #1255 in my "virgin" snews.php file (downloaded March 04.07) is in function form_articles($contents):
Quote
echo '';
OK... I think I just answered my own question, so here it is for anyone else.
We want to place the following just under the list of HTML Edit button strings. Search for the last of these within function form_articles($contents) and insert the function statement where shown (in blue):
Quote
html_input('button', 'include', '', 'Include', '', 'button', 'onclick="tag(\'include\')"', '', '', '', '', '', '', '', '');
         echo '

';
        InterneLinky();
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU
Pages: [1] 2 3 4