Layouting help

More
11 Jul 2014 12:30 - 12 Jul 2014 14:13 #4701 by rowan
Layouting help was created by rowan
Hi Thomas,

I'm attempting to create a few layouts for Sermon Speaker which all going well I'd like to contribute via github, however I'm still trying to get my head around how to call the variables properly.

So at the moment I'm working from a copy of the standard table layout, I'm trying to create an alternate table view. In my table I'd like a button called 'listen' which plays the mp3 file directly (rather than going to the details page).

So at the moment I've got
Code:
<a href="<?php echo $this-item->audiofile; ?>"<button class="btn ss-play" type="button">LISTEN</button></a>

At the moment thats just giving me a white page because of what Im putting in the href .

Any tips or should I provide the whole file for you to have a look at?

Thanks
Rowan
Attachments:
Last edit: 12 Jul 2014 14:13 by rowan.

Please Log in or Create an account to join the conversation.

More
11 Jul 2014 13:44 #4703 by Thomas Hunziker
Replied by Thomas Hunziker on topic Layouting help
In the table layout, you are likely working withing the foreach present there. So you need to work with the iterated item object ($item) instead of the object array ($this->items).

So try with
Code:
<a href="<?php echo $item->audiofile; ?>"><button class="btn ss-play" type="button">LISTEN</button></a>
and it should work.
The following user(s) said Thank You: rowan

Please Log in or Create an account to join the conversation.

More
11 Jul 2014 14:46 #4704 by rowan
Replied by rowan on topic Layouting help
Awesome I think that's worked!

I'm currently working on a localhost and Im getting a 404 not found error which says

'The requested URL /components/com_sermonspeaker/media/default_sermon.mp3 was not found on this server.'

But Im wondering if its a local host thing because the url it goes to is
http://localhost:8888/components/com_sermonspeaker/media/default_sermon.mp3

so its missing out the site name after the 8888 and before the components.

So anyway I think it'll work if I pushed it to a live site... One way to find out i guess!

Thanks

Please Log in or Create an account to join the conversation.

More
11 Jul 2014 16:26 #4705 by Thomas Hunziker
Replied by Thomas Hunziker on topic Layouting help
The host and port should be added by the browser I think, since it's a relative URL.
You can try using
Code:
<?php echo SermonspeakerHelperSermonspeaker::makeLink($item->audiofile); ?>
Maybe that works better.
The following user(s) said Thank You: rowan

Please Log in or Create an account to join the conversation.

More
12 Jul 2014 04:56 #4706 by rowan
Replied by rowan on topic Layouting help
Perfect, thanks Thomas!

So do I take it that $item->'whatever' is equal to the name of the column in the sermon_sermons table?

It'll take me a while to get my head around the how all the php side of things works but I'm excited!

Thanks for an awesome extension, I'll try to get some things in to github soon

Please Log in or Create an account to join the conversation.

More
12 Jul 2014 10:04 #4707 by Thomas Hunziker
Replied by Thomas Hunziker on topic Layouting help
Yes, in most cases the properties of the $item object represent the columns of the database.
That's because the object is generated directly from the database using this query here: github.com/Bakual/SermonSpeaker/blob/mas...dels/sermons.php#L63

There are some special cases where the query isn't a straight loading of a column. For example the title column of the speaker and series tables are renamed in the query to speaker_title and series_title. Otherwise it would not be clear which title you want to show. :)

There is a nice tool named JDump ( extensions.joomla.org/extensions/miscellaneous/development/1509 ) which allows you to see what is actually stored within a variable.
You can then use `dump($this->items);` within your template to see what it looks like and what you can use.

Please Log in or Create an account to join the conversation.

Time to create page: 0.121 seconds
Powered by Kunena Forum