Forums

Only the first word of the title field?

salvok5 02 Feb, 2017
How do I see on the title column, only the first word of the title field?
Instead of "AVVISI ENTI ESTERNI" -> "AVVISI"
Instead of "DETERMINA SETT. LL. PP." -> "DETERMINA"
salvok5 02 Feb, 2017
I normally was using SPLIT.
it's here ?
Max_admin 02 Feb, 2017
Hi salvo,

In your table, "columns views", add:
Model.titolo:{fn:get_first_word}

Then under "functions", add a "PHP" function, name "get_first_word", and use this code:

echo explode(" ", $this->get("table_view_name.row.Model.titolo"))[0];

You will need to change the "Model" and "titolo" to your real model and title names.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
salvok5 03 Feb, 2017
Already on the "Columns views" there is already this:
docu.TITOLO:{view:link_gruppo}
how do I make a link on the record?

So it does not work:
"Columns views"
docu.TITOLO:{view:link_gruppo}{fn:get_first_word}
salvok5 03 Feb, 2017
Answer
Found the solution:

"Columns views"
docu.TITOLO:{view:link_gruppo}

"link_gruppo"
Content : {fn:get_first_word}
salvok5 03 Feb, 2017
Another problem:
Now I need to display next to also total record group by group:
Example :
AVVISI (23)
DETERMINA (2)
.......
Max_admin 03 Feb, 2017
1 Likes
Hi Salvo,

For this you will need a "hsaMany" relation, with the same table, but a different model name, all inside the same "read data" function.

In this new model you should use a group, and in the "Fields to retrieve", write this:
COUNT(NewModel.ID):docu.count


and enable the "extra fields list".

Now you can use "docu.count" in your table view:
docu.TITOLO:{view:link_gruppo} ({var:table_view.row.docu.count})


Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
salvok5 03 Feb, 2017
:D 😀 😀
Thanks.
This topic is locked and no more replies can be posted.