Quantcast
Channel: Planet Plone - Where Developers And Integrators Write
Viewing all articles
Browse latest Browse all 3535

Espen Moe-Nilssen: Linking to a catalog index

$
0
0

Background

My customer, a school, uses its own system to generate their timetables.

The timetables change all the time (they are made one week at a time, usually)

The program is from last centery, uses framesets,  and the result looks like this:

 

 

As you might notice, the teachers name is in orange and underlined. This was the only option in the program, I was not able to insert any links etc. Unfortunately, we were not able to show the names, due to a restriction in the program (only 8 characters allowed in the name). The school has about 100 teachers, so each have their own "shortname" (like MIRLUN).

 

The problem

The students want to know who "MIRLUND" is (and maybe contact her).

The employee content type will not always be in the same folder

 

The solution

First of all, I was able to embed a javascript:

 

$('document').ready(function(){

$('#main').contents().find('table').find('i').wrap(function() {
var link = $('<a/>');
var lenke = 'http://www.asvgs.no/index_redirect?index=kortnumber&index_value=' + $(this).text()
link.attr('href', lenke);
link.attr('target', '_parent');
return link;
});

});

 

This marks all words with italic text as a link.

 

You can see it here (choose "1HTA" in the "Element" drop down:

https://dl.dropboxusercontent.com/u/85125667/timeplaner/index.html

 

 

The next thing was to make a field for the "employee content type", and the index: kortnumber

Then I made a browserview (https://github.com/espenmn/medialog.redirect/blob/master/src/medialog/redirect/browser/view.py )

The browserview will redirect to the catalog index if there is just one item found.

 

In other words, if the url = http://www.asvgs.no/index_redirect?index=kortnumber&index_value=PERSON1, it will redirect to the emplyee that has shortname of "PERSON1"

 

If more than one item is found, it will show the search results"

 

How the url will work

You can redirect to any index, for example if  the site has an item with id "historie", you can link to this with:

http://www.asvgs.no/index_redirect?index=id&index_value=historie

and if an emplyee has an email, you can link to:

http://www.asvgs.no/index_redirect?index=e_post&index_value=Bjarte.Bjorgaas@hfk.no

 

To do:

As my site uses no special characters, I have not "unqouted" anything (= special characters might give you a problem).


Viewing all articles
Browse latest Browse all 3535

Trending Articles