Page 1 of 1

php: using SEF url's in modules

Posted: Sun Jan 27, 2008 10:12 pm
by jonahatan
Hi there,

first of al: I'm a total noob if it comes to php (so you know :P)

Now I'm building a website where users can download a lot of (self-made) songs (and their tabs, sheets, music, midi, etc.) and to prevent myself from coding the download links for every song I thought it would be easier to create a module that automatically adds the download links.

What I want to do is this:

I want to create a module which contains code which is roughly like this:

Code: Select all

<a href="/download/songs/song-title/song-title.mp3">download mp3</a>
<a href="/download/songs/song-title/song-title_guitar.pdf">download tabs</a>
<a href="/download/songs/song-title/song-title_music.pdf">download music</a>

(it's going to be more complicated, but this is enough to give you an idea what I need)

Now I have my songs as Joomla articles and I want to write this code in php, so that the text "song-title" is replaced by the Alias of the article.

So for example: I have a song called "My First Joomla Experience" and I made an article with the songtext and the alias "my-first-joomla-experience" and the filename of the mp3 is "my-first-joomla-experience.mp3", thus the result of the code should be:

Code: Select all

<a href="/download/songs/my-first-joomla-experience/my-first-joomla-experience.mp3">download mp3</a>
<a href="/download/songs/my-first-joomla-experience/my-first-joomla-experience_guitar.pdf">download tabs</a>
<a href="/download/songs/my-first-joomla-experience/my-first-joomla-experience_music.pdf">download music</a>

Also the link of this page is something like: http://www.somewebsite.com/songs/category/song-title so the Alias which I need is in the url. If I can't read the Alias, I should still be able to read the last part of the url, I guess?


??? Could someone briefly explain to me how I read and store the Alias from the article (if that's not done by Joomla already) and how I could write it in the code?

Thx for any help ..

ps: A link to a tutorial where I could learn exactly this would do too (I've been searching, but don't really understand what I should be searching for yet  :-[)

Re: php url's

Posted: Mon Jan 28, 2008 1:38 am
by Centella
Here is a link that might be of interest to you...

http://forum.joomla.org/index.php/topic,256463.0.html


Also look in the Developers forum ... I know there are a couple of threads in there related to SEF URLS

Good Luck.

Re: php url's

Posted: Mon Jan 28, 2008 2:19 pm
by jonahatan
I noticed that using php code in articles (even without wysiwyg-editor) or in custom HTML modules doesn't work.

this code in a custom HTML module:

Code: Select all

<?php 
echo "<p>test print.</p>";
?>


displays this on the website:
test print."; ?>


Is it possible in any way to use php in modules or should I start programming in the template code?