Thursday, 15 May 2014

jQuery: Send form by ajax

Hello,

Sometimes we want to send form data but we don't want to reload page. In this case best option is send data by ajax and jQuery. In this example we used version 1.10.2 of jQuery.

HTML code:

<form id="FORMID" accept-charset="UTF-8" action="action.php" method="POST"> <input type="text" name="username" id="username" placeholder="Write username"> </form>;

Javascript code:

$('#FORMID').on('submit', function(e)  {
$.post(
$(this).prop('action'),
{
"username": $(this).find('input[name=username]').val()
},
function(data) {
alert(data.result);
},
'json'
); return false;
});


php (action.php) code:

<?php
$username = $_POST['username'];
$ret = array();
$ret['result'] = 'OK';
return json_encode($ret);

Best regards!

Thursday, 10 April 2014

HMENU: add class to li tag

Hello,

Today I was creating a new HMENU with Typoscript and I have found a problem. I had this HMENU already configured:

temp.links = HMENU temp.links.special = list temp.links.special.value = 1,2,3,4,5 temp.links { 1 = TMENU 1 { wrap = <ul>|</ul> NO.linkWrap = <li>|</li> } }

Then I saw that I wanted to add a class in the last li tag. The solution is:

temp.links = HMENU temp.links.special = list temp.links.special.value = 1,2,3,4,5 temp.links { 1 = TMENU 1 { wrap = <ul>|</ul> NO.linkWrap = <li>|</li>|*||*|<li class="specialClasss">|</li> } }

Best regards!

Monday, 31 March 2014

TYPO3: Use session variables

Hello,

In TYPO3 is very useful to manage session variables in frontend plugins:
  • Get 'test' variable: $test = $GLOBALS['TSFE']->fe_user->getKey('ses', 'test');
  • Save  'test' variable: $GLOBALS['TSFE']->fe_user->setKey('ses', 'test', $test); $GLOBALS['TSFE']->fe_user->storeSessionData();
Regards!