Jump to content

Get thumbnail image of linked field from DB Relationsh field


Recommended Posts

Posted

In the basicRelationship template you can use HTML logic in order to show different things for different databases.

{{if $item::$customDatabaseId == 4}}
 // Show item from db 4 ... yes you can access any fields including the record image field
{{else}}
 // Everything else, i.e. what is in the template now
{{endif}}

 

Posted
3 hours ago, bfarber said:

In the basicRelationship template you can use HTML logic in order to show different things for different databases.


{{if $item::$customDatabaseId == 4}}
 // Show item from db 4 ... yes you can access any fields including the record image field
{{else}}
 // Everything else, i.e. what is in the template now
{{endif}}

 

 

That's a great tip, however I'd love to have more granular control, for example display Database 1 on database 2 one way and Database 1 on Database 3 in another way.

I can sort of get around this with CSS and display:hide but that's not ideal at all.

Posted
17 hours ago, Jacques Corby-Tuech said:

 

That's a great tip, however I'd love to have more granular control, for example display Database 1 on database 2 one way and Database 1 on Database 3 in another way.

The code for multiple databases would be …

{{if $item::$customDatabaseId == 4}}
 // Show item from db 4 ... yes you can access any fields including the record image field
{{elseif $item::$customDatabaseId == 5}}
 // Show item from db 5
{{else}}
 // Everything else, i.e. what is in the template now
{{endif}}

You can check for all sorts of things. 

That being said: I am also interested how to do this easily in a database template. Changing the theme template is easy enough, but if I would want to do that in a Pages template to be put on the Marketplace for example, the theme edit wouldn’t help me very much. 

Posted
9 minutes ago, opentype said:

The code for multiple databases would be …


{{if $item::$customDatabaseId == 4}}
 // Show item from db 4 ... yes you can access any fields including the record image field
{{elseif $item::$customDatabaseId == 5}}
 // Show item from db 5
{{else}}
 // Everything else, i.e. what is in the template now
{{endif}}

That being said: I am also interested how to do this easily in a database template. Changing the theme template is easy enough, but if I would want to do that in a Pages template to be put on the Marketplace for example, the theme edit wouldn’t help me very much. 

 

I think my point wasn't as clear as it could be. I want to be able to show items for a specific database, ie databaseID 1 in different ways depending on where it's being shown.

For example a simple list of linked items on DB2, but a complex structure on DB3.

In this case it shows items from DB1 in the same way, regardless of where they're being shown.

 

This did however solve another problem I had regarding the correct formatting for getRecipocalItems() :)

  • 2 months later...
Posted

 

On 01/05/2017 at 1:12 PM, bfarber said:

In the basicRelationship template you can use HTML logic in order to show different things for different databases.


{{if $item::$customDatabaseId == 4}}
 // Show item from db 4 ... yes you can access any fields including the record image field
{{else}}
 // Everything else, i.e. what is in the template now
{{endif}}

 

I might be wrong, as I am still trying to figure this out, but this really seems the wrong way to go about this.  What you are suggestion as a 'workaround' for this would soon become a spaghetti mess of long winded if's and else's.

This could have been implemented a lot easier and a lot more developer friendly. :)  Why not add another method to the class that would allow developers the ability to access information from the related class:

{{$related = $record->getRelatedbyKey('key');}}
{$related->customFieldDisplayByKey('related_key1')|raw}

{$related->field_10|raw}

<a href="{$related->url()}">{$related->customFieldDisplayByKey('key2')|raw}</a>

Or

{$record->getRelatedbyKey('key')->field_10|raw}

This seems a lot more logical and gives the freedom working with template code and html, without the secondary need to edit another template (which would most likely grow in a uncontrollable monster when adding many databases.

nb: the methods above are for example purposes (before I get told they do not exist).

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...