By David Montoya on Saturday, 26 March 2016
Posted in Technical Issues
Likes 0
Views 388
Votes 0
I'd like to override the default output for the Latest layout. I've gotten as far as to creating my template override, but how would I go about calling individual custom fields? The default code is using an array to echo out custom fields, and I don't know how to query specific tables other than referencing its ID.

	<?php if ($post->fields && $this->params->get('post_fields', true)) { ?>
<?php echo $this->output('site/blogs/entry/fields', array('fields' => $post->fields, 'post'=>$post)); ?>
<?php } ?>


The end-goal is to stylize and combine information from my custom fields. For example, one field has a URL description, while another has the URL. Instead of meticulously inserting proper markup in each post I can just have it taken care of automatically with custom fields.

Thanks guys! No worries for delay; I know it's the weekend.
Hello David,

I've updated the file to show you how to retrieve the value. Please have a look.
·
Tuesday, 29 March 2016 11:24
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey David,

Unfortunately right now we don't have a method to override custom field specific template files. However, you can override the template for the wrapper of the custom fields. All you need to do is to copy the file from /components/com_easyblog/themes/wireframe/blogs/entry/fields.php into your template override folder below:

/templates/JOOMLA_TEMPLATE/html/com_easyblog/blogs/entry/
·
Sunday, 27 March 2016 13:26
·
0 Likes
·
0 Votes
·
0 Comments
·
How would I go about querying a specific value of a custom field for a specific post? Here's what we're looking at.

_easyblog_fields
id | group_id | title
1 | 1 | URL Name
2 | 1 | Hyperlink

_easyblog_fields_values
id | field_id | post_id | value
70 | 1 | 34 | Google
71 | 2 | 34 | http://google.com

I know that the URL name is id=1 and Hyperlink is 2 by referencing _fields. Since value is populated in _fields_values, I know they exist. And referencing field_id I know what post they relate to. I just don't know how to query this in PHP. I can get as far as styling once database information is passed to variables, but I don't know how to call database information for Joomla.
·
Monday, 28 March 2016 05:28
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello David,

If you want to get the field value, you might want to use this code:

$model = EB::model('Fields');
$values = $model->getFieldValues($field_id, $post_id);


You need to pass in field id and the post id.
·
Monday, 28 March 2016 12:13
·
0 Likes
·
0 Votes
·
0 Comments
·
How would I use "this" to call the current post's ID?

And so, if I'm looking at this correctly, $model would then be an undeclared variable type that's defined when information is pulled with getFieldValues? Or is it an array by default? I'm not certain how EB::model() works, sorry.
·
Monday, 28 March 2016 13:13
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello David,

Hurm, may I know where you want to add this code? You can provide us the backend and FTP access so taht I can help you with this. And also, specify which file you are modifying.
·
Monday, 28 March 2016 13:32
·
0 Likes
·
0 Votes
·
0 Comments
·
Ticket information updated. I just figured out how to query the blog post's ID, but now I can't figure out how to query the field value despite what you provided. When I plug in the relevant information, I yield "EasyBlogTableFieldValue", which for what I can tell is coming from /administrator/com_easyblog/tables/fieldvalue.php as a class. No clue how I called that. ^_^;;
·
Tuesday, 29 March 2016 04:15
·
0 Likes
·
0 Votes
·
0 Comments
·
Ah! You're wonderful; thank you so much!!

...wow, I was WAY off. Still very much to learn.
·
Tuesday, 29 March 2016 11:44
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi there David,

You are most welcome. Glad to hear that your issue has been resolved now.

As a gentle reminder, kindly start a new thread if you have any other issue in the future so it will be easier for us to manage your inquiry. I will lock and mark this thread as resolved.
·
Tuesday, 29 March 2016 11:46
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post