Jump to content

How to add a description to title or other form fileds


sobrenome

Recommended Posts

I think this is not possible. You want to submit a new topic in your forum with Title, tags, description and post? What is the sense to do that? Where do you want to display this description? In the topic itself or in the list of topics of this subforum?

Link to comment
Share on other sites

Sorry @sobrenome I did not understand you.

Do that is not so complicate it. In the ACP go to "Customization - Themes - Your theme"  and select the template "Text" inside of "core - global - forms". Then you have to look inside of the template for this code:

{{if isset( $autoComplete['desc'] )}}
	<span class='ipsFieldRow_desc'>
		{$autoComplete['desc']|raw}
	</span>
{{endif}}

and change it for this one:

{{if isset( $autoComplete['desc'] )}}
	<span class='ipsFieldRow_desc'>
		{$autoComplete['desc']|raw}
	</span>
{{else}}
	<span class='ipsFieldRow_desc'>
		Title description for sobrenome
	</span>
{{endif}}

Of course you can put a language variable instead to write directly the description in the template.

This is the result:

 

sobrenome.png

Link to comment
Share on other sites

Is there a way to test the field to make sure that it is the title field?

And what if I want to add a Font Awsome icon (?) beside the form fields to trigger a modal window on click to explain better how to fill the field with the best pratices?

thanks a lot!

Link to comment
Share on other sites

Yes it is a way. You are right, the way I gave you put the description not only in the title field but also in another inputs like password and username in the ACP lol With this code the description will appear just in the title field:

{{if isset( $autoComplete['desc'] )}}
	<span class='ipsFieldRow_desc'>
		{$autoComplete['desc']|raw}
	</span>
{{elseif $name == 'topic_title'}}
	<span class='ipsFieldRow_desc'>
		Title description for sobrenome
	</span>
{{endif}}

Regarding the icon (?) with the modal I am sure you can do it, you just need to include the icon and the href after the description, but I am not sure about the code to display the modal, maybe some colleague...

Link to comment
Share on other sites

Here you have it (last time, next one you should try it haha)

{{$valueAsArray = is_array( $value ) ? $value : explode( ',', $value );}}
{{if ( isset( $autoComplete['freeChoice'] ) && !$autoComplete['freeChoice'] ) || ( isset( $autoComplete['prefix'] ) and $autoComplete['prefix'] ) }}
<div {{if isset( $autoComplete['freeChoice'] ) && !$autoComplete['freeChoice']}}class="ipsJS_show"{{endif}} {{if isset( $autoComplete['prefix'] ) and $autoComplete['prefix']}}data-controller='core.global.core.prefixedAutocomplete'{{endif}}>
{{endif}}
  {{if $name == 'topic_title'}}HTML Before{{endif}}
  <input
		type="{$type}"
		name="{$name}"
		value="{{if is_array( $value )}}{expression="implode( ',', $value )"}{{else}}{$value}{{endif}}"
		id="elInput_{{if ! empty($htmlId)}}{$htmlId}{{else}}{$name}{{endif}}"
		{{if $required === TRUE}}aria-required='true'{{endif}}
		{{if $maxlength !== NULL}}maxlength="{$maxlength}"{{endif}}
		{{if $size !== NULL}}size="{$size}"{{endif}}
		{{if $disabled}}disabled aria-disabled='true'{{endif}}
		{{if $autoComplete !== NULL}}
			data-ipsAutocomplete
			{{if isset( $autoComplete['freeChoice'] ) && !$autoComplete['freeChoice']}}data-ipsAutocomplete-freeChoice='false'{{endif}}
			{{if isset( $autoComplete['forceLower'] ) && $autoComplete['forceLower']}}data-ipsAutocomplete-forceLower{{endif}}
			{{if isset( $autoComplete['maxItems'] )}}data-ipsAutocomplete-maxItems='{$autoComplete['maxItems']}'{{endif}}
			{{if !empty($autoComplete['unique'])}}
				data-ipsAutocomplete-unique
			{{endif}}
			{{if isset($autoComplete['source']) AND is_array( $autoComplete['source'] )}}
				list='{$name}_datalist'
			{{elseif !empty($autoComplete['source'])}}
				data-ipsAutocomplete-dataSource="{url="{$autoComplete['source']}"}"
				data-ipsAutocomplete-queryParam='input'
			{{endif}}
			{{if !empty($autoComplete['resultItemTemplate'])}}
				data-ipsAutocomplete-resultItemTemplate="{$autoComplete['resultItemTemplate']}"
			{{endif}}
			{{if isset( $autoComplete['minLength'] )}}data-ipsAutocomplete-minLength='{$autoComplete['minLength']}'{{endif}}
			{{if isset( $autoComplete['maxLength'] )}}data-ipsAutocomplete-maxLength='{$autoComplete['maxLength']}'{{endif}}
			{{if isset( $autoComplete['minAjaxLength'] )}}data-ipsAutocomplete-minAjaxLength='{$autoComplete['minAjaxLength']}'{{endif}}
		{{endif}}
		{{if $placeholder !== NULL}}placeholder='{$placeholder}'{{endif}}
		{{if $regex !== NULL}}pattern="{$regex}"{{endif}}
	>
    {{if $name == 'topic_title'}}HTML After{{endif}}

This is at the beggining of the same template "Text", you can see there where you can include html after or before. Here you have the result:

html.thumb.png.985ff1bbb31785ea2ed1e4b00

 

Send me one beer ticket by mail :lol:

Link to comment
Share on other sites

Unfortunately the description text does not lie under the form field, but beside it:

desc-title.thumb.gif.814726a84efa4eebaea

If there is a loop searching for descriptions related to form fields, it must have a way to add new descriptions to other fields without changing the template, but feeding some table on database. Is that correct?

Link to comment
Share on other sites

Should be nice if someone from IPS could give us a hint so the implementation would be easier and less invasive, making the enviroment more relible in upgrades.

​So far I know you can only import language strings with a plugin/app.
See the attached plugin it does really nothing except for adding one language string which is the topic title description.
Open the .xml file in an editor and change 

This is a test topic title

to the topic title description that you want, after that install the plugin.
I'm not too sure if there is another way of importing language strings but this should work fine until all the docs are pushed out.

 

Import Lang.xml

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...