8 Posts
MattBuzza
9 years ago
9
Topic

Hello All, 

I hope someone will be able to help me out a bit here as I have started to go around in circles.

I have created a folder called activities and setup a form  that uses the Joomla article title and the other standard joomla fields for published etc and added a couple of other fields in their own folder to hold a description and an icon.  This all works and I can add activities with the other data no problem and I can see the content when I view a single activity.

I have another form for centres and in this form I have a dynamic field that shows a list of the activities with multiple chosen

so far so good, I can add a centre and choose an activities and the resulting ID's are stored in e.g. 16,37

The problem I have now is that in the content view for centres i want to show the activity icon based on the chosen activity for the centre. I just do not seem to be able to get to it. 

If i show the dynamic field in the content display it shows me the correct text value (from title) but I am not able to find a way to get through the relationship between the centre, joomla article id to the activity table to get hold of the icon that corresponds to the activity.

I am quite new to this so was not sure what terms exactly to search on to see if this has been covered before so sorry if its a repeat.

Thanks in advance to anyone who might be able to point me to the right tutorial or the right direction.

Rgds

Matt

Get a VIP membership
449 Posts
gebeer
9 years ago
1
Level 1

Hello Matt and welcome to the forum.

I had a similar scenario. The only way I got it to work was making a custom DB query.

To accomplish this you can either use the before render field from Code Pack plugin to place the PHP for the DB query or if you don't want to buy that extension you can use a position override where you place your PHP code.

You'd need to make that position override for your centres' content.

More info on position overrides.

More info on Joomla custom DB queries.

8 Posts
MattBuzza
9 years ago
0
Level 2

Hello Gebeer,

Thank you very much for your help on this one I will take a look at both the options you have given me that's a great help.  

Last night I started experimenting with a different idea of using a FieldX on a related article field to get a join between to show up and then tried to validate a list of activities as a module against the variable int id of the centre being viewed based on my related article but that did not seem to work either unless because there are multiple i setup the int id part incorrectly in the list but it showed either all the records or none.

Anyway a 1000 thanks for your response to my question I will investigate the options you have kindly given me and see where that leads.

Best Rgds

Matt

449 Posts
gebeer
9 years ago
3
Level 1

Hi Matt,

funny how people come to the same conclusions. I did exactly what you came up with. FieldX on related article field. And then a List module to show the related articles. And it works for me after a lot of trial and error.

What I found that you must set the storage for your FieldX to custom Article introtext[your_fieldx]. Otherwise the values won't be picked up by your List&Search type.

In your activities List&Search, you search against your article related field with int id.

Hope that helps.

8 Posts
MattBuzza
9 years ago
2
Level 2

Hi Gebeer,

Yeah it is funny how people end up trying the same things, I did get the Fieldx test to work in terms of it holding multiple entries and then I thought ah maybe now I have this I could use SD Databaser to run an SQL query on my activities against the *value* of the id in the fieldx but I am having now trouble with this and in searching the forums I saw a post that you had made an entry in with no conclusion from around 28 days ago asking when SD Databaser would be compatible with 3.3.5 so now I am wondering if its not me and its just not working correctly as I am using 3.3.6.

Do you know if SD Databaser is supposed to work with this version yet by any chance ?

Thanks in advance for your help again.

Best regards

Matt

449 Posts
gebeer
9 years ago
1
Level 3

Again, I was trying to go the same route with SD Databaser. Major problem is that the length of the field where you put in your query is restricted to 255 characters. Unfortunately Simon, the developer, doesn't seem to actively develop his plugins any further. I tried contacting him through his website some 3 weeks ago but haven't heard back from him yet. Laso no reaction from his side to comments on his plugins in the shop or forum posts related to his plugins.

I then used the before render field from the Code Pack extension to make my custom query which was working fine.

But finally I ended up placing my query in a template position override. This is my favorite way of doing things in Seblod because it gives me better control over rendering the HTML. Particularily it helps me to avoid the div-clutter that comes with standard HTML output of seb_one and seb_blog templates. I also work a lot with the _markup.php file inside /fields folder of the templates to avoid unnecessary wrapping divs.

Best regards

Gerhard

8 Posts
MattBuzza
9 years ago
0
Level 4

Hi Gerhard,

Thank you so much for your replies and help I really appreciate it and hope that this thread helps also others trying to achieve the same. I will push on experimenting with the options you have kindly presented,  l will let you know how I get on and hopefully will have a final solution to my particular scenario to post here for others.

Best regards

Matt

8 Posts
MattBuzza
9 years ago
0
Level 1

Hi Gerhard,

Hopefully this helps others, I managed to get what I wanted working in a rather crude way at the moment using position overrides and a db query as per your suggestion for my prototype.

I setup a fieldx to my related activities which enabled me to add the activities to the center e.g surfing, biking, sailing etc 

Then setup a position override for the center, mainbody

Put a db query in the template along with the php to deal with matching the fieldx values against the array of activities and put the icon next for the page.

I don't like having to put the logic in the templates to be honest so in the end I will probably try with the Code Pack Plugin you also suggested previously to try and leave the templates as clean as possible.

Thanks again for all your help

Best regards

Matt

8 Posts
MattBuzza
9 years ago
1
Level 1

Hi All, 

Expanding on my experimentation and working from the ideas that gebeer kindly posted here for me I thought I would post my progress with a real example in the hope it helps someone out.

After trying with the fieldx method I went  back to the idea of trying again with a Dynamic field just to see how it all pulls together.

The example below is quite crude but it showed the process worked even if it would need quite some refining before putting it in a live situation.

Example of the getValue of my dyamic field was  1,7  for two activities and I wanted the icons for those activities which were in activities content type and related to the center content type by a Dynamic field with Multi Select.


<?php
$ai = array($cck->getValue('dynamicfieldname'));
?>

<?php
$activityIDS = implode(',', $ai);
$query
->select($db->quoteName(array('id', activity_icon')))
->from($db->quoteName('#__cck_store_form_activities'))
->where($db->quoteName('id') . ' in (' . $activityIDS . ')');

$db->setQuery($query);
$row = $db->loadObjectList();
echo '<h5>Activities</h5>';
/* print_r($row); */
foreach ($row as $val) {

echo "<img src=\"/" . $val->mbc_activity_icon . "\" /> ";
}

?>

Hope this helps someone.

Best rgds

Matt

449 Posts
gebeer
9 years ago
0
Level 2

Hi Matt,

great and thanks for sharing!

Get a VIP membership