[ANSWERED] Add javascript to the bottom of each item

More
7 years 9 months ago - 7 years 9 months ago #62873 by jeffhoneyager
I need to add this to the bottom of every item:
Code:
<div style="text-align: right;"><strong>This document is valid when printed for 5 days from its Print Date of: <script type="text/javascript">var today = new Date(); var dd = today.getDate(); var mm = today.getMonth()+1; //January is 0! var yyyy = today.getFullYear(); if(dd<10) { dd='0'+dd } if(mm<10) { mm='0'+mm } today = mm+'/'+dd+'/'+yyyy; document.write(today);</script> </strong></div>

It displays if I add it to the item content (i.e. description), but I don't want the end user to remember it.
I added a field (textarea) and set the default value to the above javascript. Then placed the field in the bottom position of the template. It displays the text but not the date.

Any ideas on how to display the javascript in this field?
Last edit: 7 years 9 months ago by ggppdk.

Please Log in or Create an account to join the conversation.

More
7 years 9 months ago #62878 by micker
2 way create a text field put your code at default and set top use it for all value
You can hide field for form
Or
Duplicate your template item ans édit to put your code

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

Please Log in or Create an account to join the conversation.

More
7 years 9 months ago - 7 years 9 months ago #62891 by ggppdk
Hello

you can do in a number of ways,

1. you can add at the bottom of your ITEM Layout of your custom FLEXIContent template
components/com_flexicontent/templates/mytemplate/item(_html5).php
Code:
<script> .... your code </script>


2. to use JS file at the document head:
components/com_flexicontent/templates/mytemplate/js/item.js

and then edit:
components/com_flexicontent/templates/mytemplate/item.xml

and find at the bottom
Code:
<jsitem> ... </jsitem>
and add between them:
Code:
<file>js/item.js</file>
3. If you want different JS for every item, then you can create a textarea field
and set its filtering to none (DO NOT allow this to frontend / non-privileged users !!)


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...
Last edit: 7 years 9 months ago by ggppdk.

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.516 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline