Jump to content

How to make a custom block showing an image?


Gauravk

Recommended Posts

create the database feed block you want then edit and go to "Content"  click on  "Use this template as-is Use as a base for a custom template"  and then add this on top or somewhere of the database template you created 

<p align="center"><a><img src="IMAGE LINK" alt="hellshammers" width="290" height="160"></a></p>

 

Link to comment
Share on other sites

Here is the advice_new block codes:

{{if !empty( $records ) }}
<h3 class='ipsWidget_title ipsType_reset'>{lang="block_latest_records" sprintf="$database->recordWord( 2, TRUE )"}</h3>
	{{if $orientation == 'vertical'}}
		<div class='ipsPad_half ipsWidget_inner'>
			<ul class='ipsDataList ipsDataList_reducedSpacing'>
				{{foreach $records as $record}}
					<li class='ipsDataItem'>
						<div class='ipsDataItem_icon ipsPos_top'>
							{template="userPhoto" group="global" app="core" params="$record->author(), 'tiny'"}
						</div>
                      		<div class='ipsDataItem_main'>
							<div class="ipsCommentCount ipsPos_right {{if ( $record->record_comments ) === 0}}ipsFaded{{endif}}" data-ipsTooltip title='{lang="replies_number" pluralize="$record->record_comments"}'>{expression="$record->record_comments"}</div>
							<a href="{$record->url()->setQueryString( 'do', 'getLastComment' )}" title='{lang="view_this_cmsrecord" sprintf="\IPS\Member::loggedIn()->language()->addToStack( 'content_db_lang_sl_' . $record::$customDatabaseId, FALSE ), $record->_title"}' class='ipsDataItem_title ipsType_break'>{wordbreak="$record->_title"}</a><br>
							<span class='ipsType_light ipsType_small'>{lang="byline_nodate" htmlsprintf="$record->author()->link()"} · {datetime="$record->mapped('date')"}</span>
						</div>
					</li>
				{{endforeach}}
			</ul>
		</div>
	{{else}}
		<div class='ipsWidget_inner'>
			<ul class='ipsDataList'>
				{template="recordRow" group="listing" location="database" app="cms" themeClass="IPS\cms\Theme" params="null, null, $records"}
			</ul>
		</div>
	{{endif}}
{{endif}}

 

Link to comment
Share on other sites

An image field’s full URL can be used in any Pages template (including blocks) like this:

{file="$record->field_XXX" extension="cms_Records"}

XXX ist the field ID. 

For the main record image, you don’t even need an ID. It’s just:

{file="$record->record_image" extension="cms_Records"}

 

Link to comment
Share on other sites

Thanks opentype, your suggestion worked great for latest advices that uses single upload image (default IPB field).

Now Im stuck with latest classifieds and business listing that is using multiple images in custom image field: https://carnity.com/classy/

Can anyone please advise how to alter below line of code for showing only one of multiple uploaded images....?

Codes for advise:

<p align="center"><a><img src="{file="$record->record_image" extension="cms_Records"}" alt="carnity" width="290" height="160"></a></p>

Codes for classifieds and business listings:

Business listing code
<p align="center"><a><img src={$record->customFieldDisplayByKey('bl_company_images', 'display')|raw}</a></p>

Classifieds code
<p align="center"><a><img src={$record->customFieldDisplayByKey('images', 'display')|raw}</a></p>

 

Link to comment
Share on other sites

Archived

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

  • Recently Browsing   0 members

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