script

Tuesday, August 13, 2013

Working of Favicon icon in IE

<link rel="shortcut icon" href="http://www.test.com/favicon.ico" type="image/x-icon" />

Wednesday, August 7, 2013

Get single field from flexform in TYPO3

$this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'NAME_OF_FIELD', 'sDEF');

Saturday, August 3, 2013

Remove Read More link from tt_news using typoscript.

For List View

plugin.tt_news.displayList.subheader_stdWrap.append >

For Latest View

plugin.tt_news.displayLatest.subheader_stdWrap.append >











Friday, July 12, 2013

Initialize Flexform in TYPO3

Copy Below Lines inside ext_tables.php


// flexform initialization
$TCA["tt_content"]["types"]["list"]["subtypes_addlist"][$_EXTKEY."_pi1"]="pi_flexform";
t3lib_extMgm::addPiFlexFormValue($_EXTKEY."_pi1", "FILE:EXT:".$_EXTKEY."/flexform_ds.xml");

Wednesday, May 22, 2013

languages markers for extensions

$markerArray = array();
        $basePath = 'EXT:' . $this->extKey . '/' . dirname($this->scriptRelPath) . '/locallang.xml';
        $languageArray  = $this->LOCAL_LANG = t3lib_div::readLLfile($basePath,$this->LLkey,$GLOBALS['TSFE']->renderCharset);
               
       
        if($GLOBALS['TSFE']->sys_language_uid==0)
        {
            $key = 'default';
        }else
        {
            $res = $GLOBALS["TYPO3_DB"]->exec_SELECTquery("st.lg_iso_2","sys_language sl INNER JOIN static_languages st ON st.uid=sl.static_lang_isocode","sl.uid='".$GLOBALS['TSFE']->sys_language_uid."'");
            $row = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($res);
            $key = strtolower($row["lg_iso_2"]);
        }
       
       
       
        foreach($languageArray[$key] as $key=>$val)
        {
        $index = '###'.strtoupper($key).'###';
        $markerArray[$index] = $this->pi_getLL($key);
        }
       

Monday, May 20, 2013

Allow tags on RTE in TYPO3


# Allow embed (Youtube) HTML tags in the RTE
lib.parseFunc_RTE.allowTags := addToList(object,param,embed)

Monday, May 13, 2013

MVC in TYPO3

var $cObj;
var $records_per_page;
var $language;
   
function __construct()
{
        $this->cObj = t3lib_div::makeInstance('tslib_cObj');
        $this->records_per_page = 5;
        $this->language = $GLOBALS['TSFE']->sys_language_uid;
}    


function test()
{

$templateFile = $this->conf['templateFile'] ? $this->conf['templateFile'] : 'EXT:imagevideo/pi1/view/image.html';
$this->template = $this->cObj->fileResource($templateFile);
$subpart = $this->cObj->getSubpart($this->template, '###GET_IMAGE###');
$markerArray = array();



return $this->cObj->substituteMarkerArrayCached($subpart, $markerArray);
}

Tuesday, April 9, 2013

News tt_news title in breadcrumb

TYPO3

TYPOSCRIPT

lib.breadcrumb = COA
lib.breadcrumb {
 10 = COA
 10{
    10 = HMENU
    10 {  
      special = rootline
      special.range = 0|-1
      1 = TMENU
      1.noBlur = 1
      1.target = _self
      1.wrap = |
      1.NO {
        doNotLinkIt = 1
        stdWrap.field = nav_title // title
        ATagTitle.field = nav_title // title
        #ATagParams =  class="breadcrumb"
        linkWrap = | || <span style="font-size:15px;"> › </span>|
      }
      
      1.CUR = 1
      1.CUR{
        doNotLinkIt = 1
        linkWrap = <span style="font-size:15px;"> › </span>|
        doNotLinkIt = 1
      }
   }
  }
  
  20 = RECORDS
  20{
    tables = tt_news
    dontCheckPid = 1
    source.data = GP:tx_ttnews|tt_news
    conf.tt_news = TEXT
    conf.tt_news.field = title
    wrap = <span style="font-size:15px;"> › </span>|
  }
}

Monday, April 8, 2013

Wizard in flexform of TYPO3

<TCEforms>
                                    <exclude>1</exclude>
                                    <label>Slider Link</label>
                                    <config>
                                        <type>input</type>
                                        <size>30</size>
                                        <max>256</max>
                                        <checkbox></checkbox>
                                        <eval>trim</eval>
                                        <wizards type="array">
                                          
                                            <link type="array">
                                                <type>popup</type>
                                                <title>Link</title>
                                                <icon>link_popup.gif</icon>
                                                <script>browse_links.php?mode=wizard</script>
                                                <JSopenParams>height=300,width=500,status=0,menubar=0,scrollbars=1</JSopenParams>
                                            </link>
                                        </wizards>
                                    </config>
                                </TCEforms>

IRRE in flex form of TYPO3

<T3DataStructure>
  <meta>
    <langDisable>1</langDisable>
  </meta>
  <sheets>
    <sDEF>
      <ROOT>
        <TCEforms>
          <sheetTitle>LLL:EXT:portfolio_function/locallang_tca.xml:portfolio_function.pi_flexform.sheettitle</sheetTitle>
        </TCEforms>
        <type>array</type>
        <el>
          <titleContainer>
                <TCEforms>
                    <tx_templavoila>
                        <title>Section Title</title>
                    </tx_templavoila>
                </TCEforms>
                <section>1</section>
                <type>array</type>
                <el>
                    <titleWrap>
                        <type>array</type>
                        <tx_templavoila>
                            <title>Slider</title>
                        </tx_templavoila>
                        <el>
                            <slider_image>
                                <TCEforms>
                                    <exclude>1</exclude>
                                    <label>Slider Image</label>
                                    <config>
                                        <type>group</type>
                                        <internal_type>file</internal_type>
                                         <allowed>gif, jpg,jpeg,png,bmp</allowed>
                                         <max_size>10000</max_size>
                                        <size>1</size>
                                    </config>
                                </TCEforms>
                            </slider_image>
                            <slider_content>
                                <TCEforms>
                                    <exclude>1</exclude>
                                    <label>Slider Content</label>
                                    <config>
                                        <type>text</type>
                                        <cols>30</cols>
                                        <rows>5</rows>
                                        <eval>required</eval>
                                      </config>
                                     
                                </TCEforms>
                            </slider_content>
                            <slider_content>
                                <TCEforms>
                                    <exclude>1</exclude>
                                    <label>Slider Content</label>
                                    <config>
                                        <type>text</type>
                                        <cols>30</cols>
                                        <rows>5</rows>
                                        <eval>required</eval>
                                      </config>
                                      <!--<defaultExtras>richtext[*]:rte_transform[flag=rte_enabled|mode=ts_css]</defaultExtras>-->
                                </TCEforms>
                            </slider_content>
                        </el>
                    </titleWrap>
                </el>
            </titleContainer>
          <!--<cat_sel>
           <TCEforms>
            <label>LLL:EXT:portfolio_function/locallang_tca.xml:portfolio_function.pi_flexform.sel_cat</label>
            <config>
             <type>select</type>
              <itemsProcFunc>tx_getCategories->getCategories</itemsProcFunc>
            </config>
            </TCEforms>
         </cat_sel>
           <sender_email>
            <TCEforms>
              <label>LLL:EXT:portfolio_function/locallang_tca.xml:portfolio_function.pi_flexform.sender_email</label>
              <config>
                <type>input</type>
                <size>25</size>
              </config>
            </TCEforms>
          </sender_email>
           <sender_name>
            <TCEforms>
              <label>LLL:EXT:portfolio_function/locallang_tca.xml:portfolio_function.pi_flexform.sender_name</label>
              <config>
                <type>input</type>
                <size>25</size>
              </config>
            </TCEforms>
          </sender_name>
          <email_subject>
            <TCEforms>
              <label>LLL:EXT:portfolio_function/locallang_tca.xml:portfolio_function.pi_flexform.email_subject</label>
              <config>
                <type>input</type>
                <size>25</size>
              </config>
            </TCEforms>
          </email_subject>-->
        </el>
       
      </ROOT>
    </sDEF>
  </sheets>
</T3DataStructure>

Wednesday, March 13, 2013

create automatic login in typo3

$UserData = $GLOBALS["TYPO3_DB"]->exec_SELECTgetrows('uid,username,password','fe_users','username="'.$user_profile['email'].'"');
           
 $loginData = array('uname' => $UserData[0]['username'], 'uident'=> $UserData[0]['password'] ,'status' =>'login');
$GLOBALS['TSFE']->fe_user->checkPid=0;
$info = $GLOBALS['TSFE']->fe_user->getAuthInfoArray();
                   
$user = $GLOBALS['TSFE']->fe_user->fetchUserRecord($info['db_user'],$loginData['uname']);
                    $login_success = $GLOBALS['TSFE']->fe_user->compareUident($user,$loginData);
 if($login_success){
$GLOBALS['TSFE']->fe_user->createUserSession($user);
header("Location:".$this->getURL($GLOBALS["TSFE"]->id));
exit;
}

Tuesday, March 5, 2013

Call function using typoscript

includeLibs.CLASS_NAME = typo3conf/ext/location_search/pi1/CLASS_NAME.php
lib.metaTag = USER
lib.metaTag{
  userFunc = user_CLASS_NAME->FUNC_NAME
}

page.headerData.5 < lib.metaTag

Thursday, February 21, 2013

loop in typo3 template

//in php code

$this->cObject = t3lib_div::makeInstance('tslib_cObj');
$templateFile = $this->conf['templateFile'] ? $this->conf['templateFile'] : 'EXT:abc/pi1/template/abc.html';
$this->template = $this->cObject->fileResource($templateFile);

// Extract the subparts from the template
$subparts['template'] = $this->cObj->getSubpart($this->template, '###MAIN_MARKER###');

$subparts['dropdown'] = $this->cObj->getSubpart($subparts['template'], '###DROPDOWN###');
$subparts['option'] = $this->cObj->getSubpart($subparts['dropdown'], '###OPTION###');


for($i=0;$i<10;$i++)
{
            // Fill marker array
            $loop['###LOOP_VAR###'] = $i;            
                                
            $contentItem .= $this->cObj->substituteMarkerArrayCached($subparts['option'], $loop);
 }
$subpartArray['###DROPDOWN###'] = $contentItem;
return $content = $this->cObj->substituteMarkerArrayCached($subparts['template'],null, $subpartArray,$markerArray);


//in html code
<select>
 <!-- ###DROPDOWN### begin -->
         <!-- ###OPTION### -->
                  <option value="###I###">###I###</option>
         <!-- ###OPTION### -->
<!-- ###DROPDOWN### end -->

</select>

Monday, February 18, 2013

Count based on condition in mysql

SELECT COUNT(IF(column=3,1,NULL)) AS Count
FROM table GROUP BY othercolumn

Sunday, January 27, 2013

PHP Code to Post on facebook



<?php
/*Code start for facebook posting*/
$page_ID = 'PAGE ID IN WHICH APPLICATION RESIDES';
$FB_APPID       =    'APP ID';
$FB_SECRET       =    'APP SECRET';

$token_url       = 'https://graph.facebook.com/oauth/access_token?client_id='.$FB_APPID.'&client_secret='.$FB_SECRET.'&grant_type=client_credentials'.'&scope=publish_stream';


$response        =  file_get_contents($token_url);
$params = null;
parse_str($response, $params);
$ACESS_TOKEN    =  $params['access_token'];

   
$data =    array( 'message'     => "MESSAGE_TEXT",
               'link'         => "LINK_TO_NEWS",
               'picture'     => "PATH_TO_IMAGE",
               'name'         => "NAME_OF_NEWS",
               'description' => "NEWS_DESCRIPTION"
             );
   

// need token
$data['access_token'] = $ACESS_TOKEN;
//$data['access_token'] = 'AAACTEbbNVLkBAG01k5U4lP4ItDhMntPZADTeSHDfZBnHAmUktBAiZAps3W2VNB0qdEyv7M4WmkhvBZCesATZCFltGXaqCPgHxKwSbssYKIgTHdqKvmEwZB';
$ch = curl_init();
//print_r($ch); exit;
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/'.$page_ID.'/feed');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
// execute and close
$return = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);

?>

Monday, January 21, 2013

Get url in typo3

function getURL($id,$additionalParams="")
    {
        $this->fullURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
        $cObject = t3lib_div::makeInstance('tslib_cObj');
        $configurations['additionalParams'] = $additionalParams;
        $configurations['returnLast'] = 'url'; // get it as URL
        $configurations['parameter'] =  $id;
        return $this->fullURL.htmlspecialchars($cObject->typolink(NULL, $configurations));
    }

Prevent files from being accessed by URL

Write below lines in .htaccess, It will then give message of forbidden

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost.*$ [NC]
RewriteRule \.(pdf|t3x|xps|JPG|t3x|exe|pdf|jpg|png|jpg|php|js)$ - [F]