#1 2013-08-08 16:29:01

Garfoune
Member
Registered: 2013-08-08
Posts: 6

Use medias linked to module

Hello,
How to use medias, integrate in a module view or page view?
My medias are already linked in backoffice, in can link, unlink and modify medias in my module.

Now it's front problem...
Thats does not work with tags like this...

<ion:authors>
    <ion:medias type=”pictures” tag=”ul”>
        <li>
            <img src=”<ion:src size='200' />” />
        </li>
      </ion:media>
</ion:authors>

Last edited by Garfoune (2013-08-08 17:14:47)

Offline

#2 2013-08-24 17:43:55

andreaspollak
Member
Registered: 2012-10-03
Posts: 27
Website

Re: Use medias linked to module

Hi,

did you solve your problem?

How did you link medias in your module? Can you share it with the community?
I'm very interested in!

Best regards

Last edited by andreaspollak (2013-08-24 17:44:49)

Offline

#3 2013-08-26 20:31:18

andreaspollak
Member
Registered: 2012-10-03
Posts: 27
Website

Re: Use medias linked to module

Got it!
Fully functional Image Picker in Demo Module, which behaves like in article.
Frontend Output is also integrated.

Posting Solution and pulling to github, after finsihing this Project.

Offline

#4 2013-09-17 07:44:15

andreaspollak
Member
Registered: 2012-10-03
Posts: 27
Website

Re: Use medias linked to module

Because somebody asked me (wal_toor) to post my solution, this are some changes I´ve done to get it working with demo module. There are several code and database changes needed. It´s not the full solution, but you´ll get an idea how to do it.

Following the syntax of other tables, the primary key for module_demo_author should be named: id_module_demo_author

Demo Module Table "module_demo_author" changes

CREATE TABLE `module_demo_author` (
  `id_module_demo_author` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `gender` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id_module_demo_author`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;



Demo Module Table "module_demo_author_media" changes 

CREATE TABLE `module_demo_author_media` (
  `id_module_demo_author` int(11) unsigned NOT NULL DEFAULT '0',
  `id_media` int(11) unsigned NOT NULL DEFAULT '0',
  `online` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `ordering` int(11) unsigned DEFAULT '9999',
  `url` varchar(255) DEFAULT NULL,
  `lang_display` varchar(3) DEFAULT NULL,
  PRIMARY KEY (`id_module_demo_author`,`id_media`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

don´t forget to change the other tables too.

Now you have to change every occurance of id_author in the codebase, to get the module working properly.


demo_author_model.php - link media table and set new primary key

protected $_media_table = 'module_demo_author';


	public function __construct()
	{
		$this->set_table($this->_author_table);
		$this->set_lang_table($this->_author_lang_table);
		$this->set_with_media_table($this->_media_table);
		$this->set_pk_name('id_module_demo_author'); //before:  $this->set_pk_name('id_author');
		
		
		parent::__construct();
	}


author_detail.php - add medias to module

...
	<fieldset>
		<a id="addMedia" class="fmButton button light">
			<i class="icon-pictures"></i><?php echo lang('ionize_label_attach_media'); ?>
		</a>

		<div id="myContainer"></div>
	</fieldset>

</form>


<script type="text/javascript">

	mediaManager.initialize({pictureContainer:'myContainer'});
	mediaManager.initParent('module_demo_author',<?php echo $id ?>);

	$('addMedia').addEvent('click', function(e)
	{
		e.stop();
		mediaManager.initialize({pictureContainer:'myContainer'});
		mediaManager.initParent('module_demo_author',<?php echo $id ?>);
		mediaManager.toggleFileManager();
	});

	mediaManager.loadMediaList('picture');
</script>


<!-- Save / Cancel buttons
…

author_list.php - example: change every occurance of id_author > id_module_demo_author

	<?php
		$id = $author['id_module_demo_author'];
	?>

demo_tags.php - change author tag to this or add new one and customize it

	public static function tag_author(FTL_Binding $tag)
	{
		$parentName = $tag->getDataParentName();

		return $tag->expand();
	}

Rendering example

<ion:demo:authors>

	<ion:author tag="ul">

		<li>

			<ion:name />

			<ion:medias type="picture" tag="ul">
				<li><img src="<ion:media:src size='180' />" /></li>
			</ion:medias>

		</li>

	</ion:author>

</ion:demo:authors>

Offline

#5 2013-12-12 17:13:38

Rel@
Member
Registered: 2013-12-12
Posts: 6

Re: Use medias linked to module

Hello,
I use Ionize from September 2013, and I have to say thanks for it.
Great, usefull ... smile

Here you find a complete module Demo use medias:
https://github.com/lremenyi/Ionize_modu … WithMedias

Kind regards

Offline

#6 2014-07-13 23:11:28

LeeSylvester
Member
Registered: 2014-07-11
Posts: 11

Re: Use medias linked to module

Hi Rel@,

This is great.  However, do you know how I might display the "description" data, which is internationalised?  As it's not in the media table, it doesn't show using a simple tag, like:

<ion:description />

Thanks,
Lee

Offline

#7 2014-07-14 11:50:49

Rel@
Member
Registered: 2013-12-12
Posts: 6

Re: Use medias linked to module

Hi Lee,
I think the answer is something like (but I doesn't test it):

<ion:article>
  <ion:authors>
    <ion:author field="description" />
  </ion:authors>
</ion:article>

Offline

#8 2014-07-14 11:52:02

LeeSylvester
Member
Registered: 2014-07-11
Posts: 11

Re: Use medias linked to module

No, I tried that, but the Author object doesn't contain the internationalised values.

Thanks though.

Offline

What's Ionize ?

Ionize is an Open Source Content Management System created by webdesigners for webdesigners.

Created and maintained by Partikule and Toopixel, Ionize wants to be the easiest and most powerful CMS.

Can I help ?

Because talent is nothing without involvement, we are looking for motivated coders and webdesigners to join the project team.

Resources

Website : ionizecms.com
Documentation : doc.ionizecms.com

Development : Ionize on GitHub
Translations : Ionize Translations