8 years ago
12
Topic

I came accross this old post

https://forum-v2.seblod.com/Fields--Plugins/40257-Rendering-fields-outside-of-Seblod-template.html

Which pretty closely describes what I'm trying to do.  Basically I need to filter articles for a blog output (handled by Joomla's blog layout menu item) on a seblod field.  So in com_content override I need to get access to the field for each article.

Is that possible?

Get a VIP membership
8 years ago
2
Level 1

Alternatively, being able to filter on the  Seblod content type would also work, just not sure how to do that through Joomla.  Can it be defined in URL?

'

4229 Posts
Kadministrator
8 years ago
1
Level 2

Why don't you just use seblod list with blog template?

8 years ago
0
Level 3

Because it doesn't do the same job and our Blog view has been  been heavily overriden with additional JS.  

This is a live site, such a change at this stage would not be a clever move given all I want to do would be very simple theother way around...

251 Posts
Viktor Iwan
8 years ago
7
Level 1

i would suggest you to use seb_minima (https://www.seblod.com/store/extensions/52) and also master about position override (https://www.seblod.com/resources/manuals/designer/overriding-a-position).. by mastering these two, you're open up for limitless layout style and injecting script as creative as you want

8 years ago
6
Level 2

Not being ungrateful for your help guys but blindly recommending new templates is not helpful and doesn't answer my question at all.

I use many of the Seblod templates already, many with position overrides.  You almost have to use those to try and limit the amount of eroneous Seblod divs created.

I'm asking about how I can filter on seblod fields from within a joomla template, if you can't answer to that please consider that I have considered carefully the use of the Joomla output and it has already gone live for the site.  Changing at this point is not an option.

251 Posts
Viktor Iwan
8 years ago
5
Level 3

Sorry for my english, but I'm trying to understand your question.. as we can have different perspective about the word 'filtering' alone...

"I'm asking about how I can filter on seblod fields from within a joomla template," <-- is this the additional 'WHERE" statement with seblod custom's field in SQL Queries when the page loads ? 

OR (based on your original post)

"Basically I need to filter articles for a blog output (handled by Joomla's blog layout menu item) on a seblod field.So in com_content override I need to get access to the field for each article." <-- is this mean you like to define a variable in template level that able to ALTER the main SQL Queries for Blog Layout?

8 years ago
4
Level 4

Hi Viktor, the second one was closest to what I meant.  In joomla if we want to access the api we call jfactory and then whatever function you need.

I was hoping for a similar ability in Seblod.  I only want to show a specific article type because I'm trying to have two article types within the same category.

On one I can use a sieblod list so I can filter that easily on the other it is output through the Joomla Blog view so a little more tricky.

4229 Posts
Kadministrator
8 years ago
3
Level 5

easiest way to do this would be to just add a right join of your seblod tabl (on pk=article.id) that holds your forms data (cck_store_your_type) to normal joomla blog query. It already has pk field which matches your article id.

8 years ago
2
Level 6

Hi Klas, thanks for your reply.  That solution sounds like what I'm trying to do but I think something missing in my knowledge to be able to implement it.

The query for the Blog view is constructed in the /models/category.php right?  Does your solution involve core hack, or have I misunderstood?  We have created a new Menu Item with a copy of the Blog View and some mods.  We needed to do this to help differentiate different layouts for the client.  Can this join be done in the Override?

4229 Posts
Kadministrator
8 years ago
1
Level 7

It is not exactly the right place to do it, but yes, you can do it there - in an override you are outputting items from a variable, nothing stops you from changing value of that variable or output completelly different items than those provided by the joomla core.

8 years ago
0
Level 8

For prosperity and future generations, this turned out to be quite easy.

The Joomla code needed to get the articles which were of a specific type, in my case accordion content types:

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('id'));
$query->from($db->quoteName('#__cck_store_form_accordion_content'));
$db->setQuery($query);
$accordions = $db->loadAssocList('id','id'); //puts all the cckIDs related to each article in the category into an indexed array

Then when looking at the category object I could see the ::cck ID:: code in the fulltext element (not sure why, I thought it was always stored in introtext but this may have been a little misconfigured by supporting site builder.

So to get the cck item ID

$cckID = ''; // BW filtering Accordion Content Type
preg_match('!\d+!', $item->fulltext, $cckID); // puts each cckID related to each article in the category into an indexed array

The the filter was simple, thie following if statement wrapped around the "leading items" output did the trick:

if (in_array( $cckID[0], $accordions )) { // filter checks that the cckId of the item is in the $accordions list from above. ?>

It's not pretty I know but for us to get this project moving without having to redo layouts and overrides etc, it was the simplest option.

4229 Posts
Kadministrator
8 years ago
0
Level 1

Some more simple way would be to use 

$SeblodUser = JCckContent::getInstance(array( 'joomla_user' , $userId));
$someValue = $SeblodUser->get('some_field', 0);

Above gets value from joomla user object using user id.

First parameter refferes to the object : joomla_user, joomla_article etc., second one is primary key in that object.

Using JCckContent class you can also save modified content and create new one.

Get a Book for SEBLOD