php: using SEF url's in modules

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
jonahatan
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Jan 21, 2008 12:55 am

php: using SEF url's in modules

Post by jonahatan » Sun Jan 27, 2008 10:12 pm

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  :-[)
Last edited by jonahatan on Mon Jan 28, 2008 2:20 pm, edited 1 time in total.

User avatar
Centella
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Thu Aug 18, 2005 5:13 am
Location: Killeen, TX
Contact:

Re: php url's

Post by Centella » Mon Jan 28, 2008 1:38 am

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.

jonahatan
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Jan 21, 2008 12:55 am

Re: php url's

Post by jonahatan » Mon Jan 28, 2008 2:19 pm

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?


Post Reply