문제

How to include a Javascript or CSS file in Yii Framework?

I want to create a page on my site that has a little Javascript application running, so I want to include .js and .css files in a specific view.

도움이 되었습니까?

해결책

Something like this:

<?php  
  $baseUrl = Yii::app()->baseUrl; 
  $cs = Yii::app()->getClientScript();
  $cs->registerScriptFile($baseUrl.'/js/yourscript.js');
  $cs->registerCssFile($baseUrl.'/css/yourcss.css');
?>

다른 팁

You can do so by adding

Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/path/to/your/script');

I liked to answer this question.

Their are many places where we have css & javascript files, like in css folder which is outside the protected folder, css & js files of extension & widgets which we need to include externally sometime when use ajax a lot, js & css files of core framework which also we need to include externally sometime. So their are some ways to do this.

Include core js files of framework like jquery.js, jquery.ui.js

<?php 
Yii::app()->clientScript->registerCoreScript('jquery');     
Yii::app()->clientScript->registerCoreScript('jquery.ui'); 
?>

Include files from css folder outside of protected folder.

<?php 
Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl.'/css/example.css');
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/css/example.js');
?>

Include css & js files from extension or widgets.

Here fancybox is an extension which is placed under protected folder. Files we including has path : /protected/extensions/fancybox/assets/

<?php
// Fancybox stuff.
$assetUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('ext.fancybox.assets'));
Yii::app()->clientScript->registerScriptFile($assetUrl.'/jquery.fancybox-1.3.4.pack.js'); 
Yii::app()->clientScript->registerScriptFile($assetUrl.'/jquery.mousewheel-3.0.4.pack.js'); 
?>  

Also we can include core framework files: Example : I am including CListView js file.

<?php
$baseScriptUrl=Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('zii.widgets.assets'));
Yii::app()->clientScript->registerScriptFile($baseScriptUrl.'/listview/jquery.yiilistview.js',CClientScript::POS_END);  
?>
  • We need to include js files of zii widgets or extension externally sometimes when we use them in rendered view which are received from ajax call, because loading each time new ajax file create conflict in calling js functions.

For more detail Look at my blog article

Easy in your conf/main.php. This is my example with bootstrap. You can see that here

'components'=>array(
    'clientScript' => array(
        'scriptMap' => array(
            'jquery.js'=>false,  //disable default implementation of jquery
            'jquery.min.js'=>false,  //desable any others default implementation
            'core.css'=>false, //disable
            'styles.css'=>false,  //disable
            'pager.css'=>false,   //disable
            'default.css'=>false,  //disable
        ),
        'packages'=>array(
            'jquery'=>array(                             // set the new jquery
                'baseUrl'=>'bootstrap/',
                'js'=>array('js/jquery-1.7.2.min.js'),
            ),
            'bootstrap'=>array(                       //set others js libraries
                'baseUrl'=>'bootstrap/',
                'js'=>array('js/bootstrap.min.js'),
                'css'=>array(                        // and css
                    'css/bootstrap.min.css',
                    'css/custom.css',
                    'css/bootstrap-responsive.min.css',
                ),
                'depends'=>array('jquery'),         // cause load jquery before load this.
            ),
        ),
    ),
),

In the view, add the following:

<?php  
  $cs = Yii::app()->getClientScript();
  $cs->registerScriptFile('/js/yourscript.js', CClientScript::POS_END);
  $cs->registerCssFile('/css/yourcss.css');
?>

Please notice the second parameter when you register the js file, it's the position of your script, when you set it CClientScript::POS_END, you let the HTML renders before the javascript is loaded.

There are many methods that we can include javascript, css into your Yii App. Today I will demonstrate three simple and helpul methods.

A simple way to add js, css by editing config/main.php

// application components
  'components'=>array(
         // ...
        'clientScript'=>array(
            'packages'=>array(
                'jquery'=>array(
                    'baseUrl'=>'//ajax.googleapis.com/ajax/libs/jquery/1/',
                    'js'=>array('jquery.min.js'),
                )
            ),
        ),
        // ...
  ),

Using getClientScript

Usually, We add in block of code into Controller or layout of your theme

$baseUrl = Yii::app()->baseUrl; 
$cs = Yii::app()->getClientScript();
$cs->registerScriptFile($baseUrl.'/js/yourscript.js');
$cs->registerCssFile($baseUrl.'/css/yourcss.css');

Or shorter:

Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/path/to/your/javascript/file',CClientScript::POS_END);
Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl.'/path/to/css/file');

Include core js files

Yii::app()->clientScript->registerCoreScript('jquery');     
Yii::app()->clientScript->registerCoreScript('jquery.ui');

Faster Yii API Document: http://yii.codexamples.com/

To include JS and CSS files in a specific view you can do it via controller by passing the parameters false, true, which will include the CSS and JS for, e.g.:

$this->renderPartial(
    'yourviewname',
    array(
        'model' => $model,
        false,
        true
    )
);

여기에 웹 서비스 호출에서 XML 덤프가 있습니다.전에이 작업을 수행하지 않았지만 첫 번째 질문에 답변하기 위해서는 각 목록의 작성자 속성을 마치 할 수 있습니다.사용자 ID가있는 것으로 보이므로 필요한 모든 것이 필요할 것임을위한 간단한 검사가 표시됩니다.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
    <GetListCollectionResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
        <GetListCollectionResult>
            <Lists>
                <List DocTemplateUrl="" DefaultViewUrl="" MobileDefaultViewUrl="" ID="{8423DC5D-C083-41C2-A28D-DAF3AF74B369}" Title="fpdatasources" Description="" ImageUrl="/_layouts/images/itdl.png" Name="{8423DC5D-C083-41C2-A28D-DAF3AF74B369}" BaseType="1" FeatureId="00bfea71-f381-423d-b9d1-da7a54c50110" ServerTemplate="110" Created="20120711 03:13:24" Modified="20120711 03:13:24" LastDeleted="20120711 03:13:24" Version="0" Direction="none" ThumbnailSize="" WebImageWidth="" WebImageHeight="" Flags="135432" ItemCount="0" AnonymousPermMask="0" RootFolder="" ReadSecurity="1" WriteSecurity="1" Author="1" EventSinkAssembly="" EventSinkClass="" EventSinkData="" EmailAlias="" WebFullUrl="/SPDev" WebId="a01bc02b-34f9-4391-bbdb-d2a82b9c7768" SendToLocation="" ScopeId="fa7b0ddb-e1c4-4999-bf54-b1912a2e9466" MajorVersionLimit="0" MajorWithMinorVersionsLimit="0" WorkFlowId="" HasUniqueScopes="False" NoThrottleListOperations="False" HasRelatedLists="" AllowDeletion="True" AllowMultiResponses="False" EnableAttachments="False" EnableModeration="False" EnableVersioning="False" HasExternalDataSource="False" Hidden="True" MultipleDataList="False" Ordered="False" ShowUser="True" EnablePeopleSelector="False" EnableResourceSelector="False" EnableMinorVersion="False" RequireCheckout="False" ThrottleListOperations="False" ExcludeFromOfflineClient="False" EnableFolderCreation="True" IrmEnabled="False" IsApplicationList="False" PreserveEmptyValues="False" StrictTypeCoercion="False" EnforceDataValidation="False" MaxItemsPerThrottledOperation="5000" />
                <List DocTemplateUrl="" DefaultViewUrl="/SPDev/_catalogs/masterpage/Forms/AllItems.aspx" MobileDefaultViewUrl="" ID="{E337C86E-8373-4A4F-A3FD-1EB58FBED882}" Title="Master Page Gallery" Description="Use the master page gallery to store master pages. The master pages in this gallery are available to this site and any sites underneath it." ImageUrl="/_layouts/images/itdl.png" Name="{E337C86E-8373-4A4F-A3FD-1EB58FBED882}" BaseType="1" FeatureId="" ServerTemplate="116" Created="20120506 07:12:54" Modified="20120621 02:13:50" LastDeleted="20120506 07:12:54" Version="5" Direction="none" ThumbnailSize="" WebImageWidth="" WebImageHeight="" Flags="41947548" ItemCount="3" AnonymousPermMask="0" RootFolder="" ReadSecurity="1" WriteSecurity="1" Author="1" EventSinkAssembly="" EventSinkClass="" EventSinkData="" EmailAlias="" WebFullUrl="/SPDev" WebId="a01bc02b-34f9-4391-bbdb-d2a82b9c7768" SendToLocation="" ScopeId="fa7b0ddb-e1c4-4999-bf54-b1912a2e9466" MajorVersionLimit="0" MajorWithMinorVersionsLimit="0" WorkFlowId="" HasUniqueScopes="False" NoThrottleListOperations="False" HasRelatedLists="" AllowDeletion="False" AllowMultiResponses="False" EnableAttachments="False" EnableModeration="False" EnableVersioning="True" HasExternalDataSource="False" Hidden="True" MultipleDataList="False" Ordered="False" ShowUser="True" EnablePeopleSelector="False" EnableResourceSelector="False" EnableMinorVersion="False" RequireCheckout="False" ThrottleListOperations="False" ExcludeFromOfflineClient="False" EnableFolderCreation="True" IrmEnabled="False" IsApplicationList="True" PreserveEmptyValues="False" StrictTypeCoercion="False" EnforceDataValidation="False" MaxItemsPerThrottledOperation="5000" />
                <List DocTemplateUrl="" DefaultViewUrl="/SPDev/Lists/ProjectAdmin/AllItems.aspx" MobileDefaultViewUrl="" ID="{E57BC9B7-1675-4B58-B794-136A5606BC18}" Title=" Project Administration" Description="" ImageUrl="/_layouts/images/itgen.png" Name="{E57BC9B7-1675-4B58-B794-136A5606BC18}" BaseType="0" FeatureId="00bfea71-de22-43b2-a848-c05709900100" ServerTemplate="100" Created="20120711 03:04:30" Modified="20120718 12:36:57" LastDeleted="20120718 12:16:50" Version="39" Direction="none" ThumbnailSize="" WebImageWidth="" WebImageHeight="" Flags="549457928" ItemCount="7" AnonymousPermMask="0" RootFolder="" ReadSecurity="1" WriteSecurity="1" Author="1" EventSinkAssembly="" EventSinkClass="" EventSinkData="" EmailAlias="" WebFullUrl="/SPDev" WebId="a01bc02b-34f9-4391-bbdb-d2a82b9c7768" SendToLocation="" ScopeId="b8927c31-76c5-4063-891d-dbc9293f9cbf" MajorVersionLimit="0" MajorWithMinorVersionsLimit="0" WorkFlowId="" HasUniqueScopes="False" NoThrottleListOperations="False" HasRelatedLists="" AllowDeletion="True" AllowMultiResponses="False" EnableAttachments="False" EnableModeration="False" EnableVersioning="False" HasExternalDataSource="False" Hidden="False" MultipleDataList="False" Ordered="False" ShowUser="True" EnablePeopleSelector="False" EnableResourceSelector="False" EnableMinorVersion="False" RequireCheckout="False" ThrottleListOperations="False" ExcludeFromOfflineClient="False" EnableFolderCreation="False" IrmEnabled="False" IsApplicationList="False" PreserveEmptyValues="False" StrictTypeCoercion="False" EnforceDataValidation="False" MaxItemsPerThrottledOperation="5000" />
                <List DocTemplateUrl="" DefaultViewUrl="/SPDev/Lists/ProjectInfo/AllItems.aspx" MobileDefaultViewUrl="" ID="{83509614-ECBD-4DEB-A1C6-718578A82569}" Title=" Project Info" Description="" ImageUrl="/_layouts/images/itcontct.png" Name="{83509614-ECBD-4DEB-A1C6-718578A82569}" BaseType="0" FeatureId="00bfea71-7e6d-4186-9ba8-c047ac750105" ServerTemplate="105" Created="20120710 08:12:13" Modified="20120719 01:03:01" LastDeleted="20120718 12:16:42" Version="102" Direction="none" ThumbnailSize="" WebImageWidth="" WebImageHeight="" Flags="616566784" ItemCount="7" AnonymousPermMask="0" RootFolder="" ReadSecurity="1" WriteSecurity="1" Author="1" EventSinkAssembly="" EventSinkClass="" EventSinkData="" EmailAlias="" WebFullUrl="/SPDev" WebId="a01bc02b-34f9-4391-bbdb-d2a82b9c7768" SendToLocation="" ScopeId="fa7b0ddb-e1c4-4999-bf54-b1912a2e9466" MajorVersionLimit="0" MajorWithMinorVersionsLimit="0" WorkFlowId="" HasUniqueScopes="False" NoThrottleListOperations="False" HasRelatedLists="" AllowDeletion="True" AllowMultiResponses="False" EnableAttachments="True" EnableModeration="False" EnableVersioning="False" HasExternalDataSource="False" Hidden="False" MultipleDataList="False" Ordered="False" ShowUser="True" EnablePeopleSelector="False" EnableResourceSelector="False" EnableMinorVersion="False" RequireCheckout="False" ThrottleListOperations="False" ExcludeFromOfflineClient="False" EnableFolderCreation="False" IrmEnabled="False" IsApplicationList="False" PreserveEmptyValues="False" StrictTypeCoercion="False" EnforceDataValidation="False" MaxItemsPerThrottledOperation="5000" />
                <List DocTemplateUrl="/SPDev/pages/Forms/_webpartpage.htm" DefaultViewUrl="/SPDev/pages/Forms/AllItems.aspx" MobileDefaultViewUrl="" ID="{6EA1D15C-EC6B-4D5D-A072-1C549E073A46}" Title="pages" Description="" ImageUrl="/_layouts/images/itdl.png" Name="{6EA1D15C-EC6B-4D5D-A072-1C549E073A46}" BaseType="1" FeatureId="00bfea71-e717-4e80-aa17-d0c71b360101" ServerTemplate="101" Created="20120506 07:16:30" Modified="20120829 06:57:42" LastDeleted="20120714 06:24:04" Version="17" Direction="none" ThumbnailSize="" WebImageWidth="" WebImageHeight="" Flags="12587144" ItemCount="8" AnonymousPermMask="0" RootFolder="" ReadSecurity="1" WriteSecurity="1" Author="1" EventSinkAssembly="" EventSinkClass="" EventSinkData="" EmailAlias="" WebFullUrl="/SPDev" WebId="a01bc02b-34f9-4391-bbdb-d2a82b9c7768" SendToLocation="|" ScopeId="fa7b0ddb-e1c4-4999-bf54-b1912a2e9466" MajorVersionLimit="0" MajorWithMinorVersionsLimit="0" WorkFlowId="" HasUniqueScopes="False" NoThrottleListOperations="False" HasRelatedLists="" AllowDeletion="True" AllowMultiResponses="False" EnableAttachments="False" EnableModeration="False" EnableVersioning="True" HasExternalDataSource="False" Hidden="False" MultipleDataList="False" Ordered="False" ShowUser="True" EnablePeopleSelector="False" EnableResourceSelector="False" EnableMinorVersion="False" RequireCheckout="False" ThrottleListOperations="False" ExcludeFromOfflineClient="False" EnableFolderCreation="True" IrmEnabled="False" IsApplicationList="False" PreserveEmptyValues="False" StrictTypeCoercion="False" EnforceDataValidation="False" MaxItemsPerThrottledOperation="5000" />
                <List DocTemplateUrl="" DefaultViewUrl="/SPDev/Lists/ProjectTasks/AllItems.aspx" MobileDefaultViewUrl="" ID="{37747111-B544-4752-8AEF-FD2B2FF10ACC}" Title="Project Tasks" Description="" ImageUrl="/_layouts/images/itissue.png" Name="{37747111-B544-4752-8AEF-FD2B2FF10ACC}" BaseType="5" FeatureId="00bfea71-5932-4f9c-ad71-1557e5751100" ServerTemplate="1100" Created="20120808 12:56:57" Modified="20120824 08:23:33" LastDeleted="20120824 08:23:33" Version="83" Direction="none" ThumbnailSize="" WebImageWidth="" WebImageHeight="" Flags="616566912" ItemCount="42" AnonymousPermMask="0" RootFolder="" ReadSecurity="1" WriteSecurity="1" Author="1" EventSinkAssembly="" EventSinkClass="" EventSinkData="" EmailAlias="" WebFullUrl="/SPDev" WebId="a01bc02b-34f9-4391-bbdb-d2a82b9c7768" SendToLocation="" ScopeId="fa7b0ddb-e1c4-4999-bf54-b1912a2e9466" MajorVersionLimit="0" MajorWithMinorVersionsLimit="0" WorkFlowId="" HasUniqueScopes="False" NoThrottleListOperations="False" HasRelatedLists="" AllowDeletion="True" AllowMultiResponses="False" EnableAttachments="True" EnableModeration="False" EnableVersioning="True" HasExternalDataSource="False" Hidden="False" MultipleDataList="False" Ordered="False" ShowUser="True" EnablePeopleSelector="False" EnableResourceSelector="False" EnableMinorVersion="False" RequireCheckout="False" ThrottleListOperations="False" ExcludeFromOfflineClient="False" EnableFolderCreation="False" IrmEnabled="False" IsApplicationList="False" PreserveEmptyValues="False" StrictTypeCoercion="False" EnforceDataValidation="False" MaxItemsPerThrottledOperation="5000" EnableAssignedToEmail="False" />
                <List DocTemplateUrl="" DefaultViewUrl="/SPDev/Lists/Projects/gantt.aspx" MobileDefaultViewUrl="" ID="{49AFC299-FC30-4EE9-9571-50B3B366969E}" Title="Projects" Description="" ImageUrl="/_layouts/images/itgantt.png" Name="{49AFC299-FC30-4EE9-9571-50B3B366969E}" BaseType="0" FeatureId="00bfea71-513d-4ca0-96c2-6a47775c0119" ServerTemplate="150" Created="20120808 12:54:59" Modified="20120828 12:11:52" LastDeleted="20120808 12:54:59" Version="4" Direction="none" ThumbnailSize="" WebImageWidth="" WebImageHeight="" Flags="549457920" ItemCount="23" AnonymousPermMask="0" RootFolder="" ReadSecurity="1" WriteSecurity="1" Author="1" EventSinkAssembly="" EventSinkClass="" EventSinkData="" EmailAlias="" WebFullUrl="/SPDev" WebId="a01bc02b-34f9-4391-bbdb-d2a82b9c7768" SendToLocation="" ScopeId="fa7b0ddb-e1c4-4999-bf54-b1912a2e9466" MajorVersionLimit="0" MajorWithMinorVersionsLimit="0" WorkFlowId="" HasUniqueScopes="False" NoThrottleListOperations="False" HasRelatedLists="" AllowDeletion="True" AllowMultiResponses="False" EnableAttachments="True" EnableModeration="False" EnableVersioning="False" HasExternalDataSource="False" Hidden="False" MultipleDataList="False" Ordered="False" ShowUser="True" EnablePeopleSelector="False" EnableResourceSelector="False" EnableMinorVersion="False" RequireCheckout="False" ThrottleListOperations="False" ExcludeFromOfflineClient="False" EnableFolderCreation="False" IrmEnabled="False" IsApplicationList="False" PreserveEmptyValues="False" StrictTypeCoercion="False" EnforceDataValidation="False" MaxItemsPerThrottledOperation="5000" />
                <List DocTemplateUrl="" DefaultViewUrl="/SPDev/scripts/Forms/AllItems.aspx" MobileDefaultViewUrl="" ID="{65B97AAC-AF58-4A11-8ED5-791B5E4D3633}" Title="scripts" Description="" ImageUrl="/_layouts/images/itdl.png" Name="{65B97AAC-AF58-4A11-8ED5-791B5E4D3633}" BaseType="1" FeatureId="00bfea71-e717-4e80-aa17-d0c71b360101" ServerTemplate="101" Created="20120506 07:19:03" Modified="20120829 04:33:37" LastDeleted="20120630 01:54:59" Version="4" Direction="none" ThumbnailSize="" WebImageWidth="" WebImageHeight="" Flags="8392840" ItemCount="78" AnonymousPermMask="0" RootFolder="" ReadSecurity="1" WriteSecurity="1" Author="1" EventSinkAssembly="" EventSinkClass="" EventSinkData="" EmailAlias="" WebFullUrl="/SPDev" WebId="a01bc02b-34f9-4391-bbdb-d2a82b9c7768" SendToLocation="" ScopeId="fa7b0ddb-e1c4-4999-bf54-b1912a2e9466" MajorVersionLimit="0" MajorWithMinorVersionsLimit="0" WorkFlowId="" HasUniqueScopes="False" NoThrottleListOperations="False" HasRelatedLists="" AllowDeletion="True" AllowMultiResponses="False" EnableAttachments="False" EnableModeration="False" EnableVersioning="True" HasExternalDataSource="False" Hidden="False" MultipleDataList="False" Ordered="False" ShowUser="True" EnablePeopleSelector="False" EnableResourceSelector="False" EnableMinorVersion="False" RequireCheckout="False" ThrottleListOperations="False" ExcludeFromOfflineClient="False" EnableFolderCreation="True" IrmEnabled="False" IsApplicationList="False" PreserveEmptyValues="False" StrictTypeCoercion="False" EnforceDataValidation="False" MaxItemsPerThrottledOperation="5000" />
                <List DocTemplateUrl="" DefaultViewUrl="/SPDev/SitePages/Forms/AllPages.aspx" MobileDefaultViewUrl="" ID="{81AE07D3-AA27-4FE1-8B24-F2B31CD1C0B2}" Title="Site Pages" Description="Use this library to create and store pages on this site." ImageUrl="/_layouts/images/itwp.png" Name="{81AE07D3-AA27-4FE1-8B24-F2B31CD1C0B2}" BaseType="1" FeatureId="00bfea71-c796-4402-9f2f-0eb9a6e71b18" ServerTemplate="119" Created="20120615 06:28:12" Modified="20120801 04:33:55" LastDeleted="20120801 04:33:55" Version="4" Direction="none" ThumbnailSize="" WebImageWidth="" WebImageHeight="" Flags="545263752" ItemCount="2" AnonymousPermMask="0" RootFolder="" ReadSecurity="1" WriteSecurity="1" Author="1" EventSinkAssembly="" EventSinkClass="" EventSinkData="" EmailAlias="" WebFullUrl="/SPDev" WebId="a01bc02b-34f9-4391-bbdb-d2a82b9c7768" SendToLocation="" ScopeId="fa7b0ddb-e1c4-4999-bf54-b1912a2e9466" MajorVersionLimit="0" MajorWithMinorVersionsLimit="0" WorkFlowId="" HasUniqueScopes="False" NoThrottleListOperations="False" HasRelatedLists="" AllowDeletion="True" AllowMultiResponses="False" EnableAttachments="False" EnableModeration="False" EnableVersioning="True" HasExternalDataSource="False" Hidden="False" MultipleDataList="False" Ordered="False" ShowUser="True" EnablePeopleSelector="False" EnableResourceSelector="False" EnableMinorVersion="False" RequireCheckout="False" ThrottleListOperations="False" ExcludeFromOfflineClient="False" EnableFolderCreation="False" IrmEnabled="False" IsApplicationList="True" PreserveEmptyValues="False" StrictTypeCoercion="False" EnforceDataValidation="False" MaxItemsPerThrottledOperation="5000" />
                <List DocTemplateUrl="" DefaultViewUrl="/SPDev/SiteImages/Forms/AllItems.aspx" MobileDefaultViewUrl="" ID="{8D08C7F3-BE02-4B27-9D92-6496439F0230}" Title="SiteImages" Description="" ImageUrl="/_layouts/images/itil.png" Name="{8D08C7F3-BE02-4B27-9D92-6496439F0230}" BaseType="1" FeatureId="00bfea71-52d4-45b3-b544-b1c71b620109" ServerTemplate="109" Created="20120626 07:30:52" Modified="20120821 02:42:51" LastDeleted="20120626 07:30:52" Version="4" Direction="none" ThumbnailSize="160" WebImageWidth="640" WebImageHeight="480" Flags="8392712" ItemCount="8" AnonymousPermMask="0" RootFolder="" ReadSecurity="1" WriteSecurity="1" Author="1" EventSinkAssembly="" EventSinkClass="" EventSinkData="" EmailAlias="" WebFullUrl="/SPDev" WebId="a01bc02b-34f9-4391-bbdb-d2a82b9c7768" SendToLocation="" ScopeId="fa7b0ddb-e1c4-4999-bf54-b1912a2e9466" MajorVersionLimit="0" MajorWithMinorVersionsLimit="0" WorkFlowId="" HasUniqueScopes="False" NoThrottleListOperations="False" HasRelatedLists="" AllowDeletion="True" AllowMultiResponses="False" EnableAttachments="False" EnableModeration="False" EnableVersioning="False" HasExternalDataSource="False" Hidden="False" MultipleDataList="False" Ordered="False" ShowUser="True" EnablePeopleSelector="False" EnableResourceSelector="False" EnableMinorVersion="False" RequireCheckout="False" ThrottleListOperations="False" ExcludeFromOfflineClient="False" EnableFolderCreation="True" IrmEnabled="False" IsApplicationList="False" PreserveEmptyValues="False" StrictTypeCoercion="False" EnforceDataValidation="False" MaxItemsPerThrottledOperation="5000" />
                <List DocTemplateUrl="" DefaultViewUrl="/SPDev/Lists/Tasks/AllItems.aspx" MobileDefaultViewUrl="" ID="{FA2AB648-85DE-4068-83E5-F7EEA1BB4DD2}" Title="Tasks" Description="" ImageUrl="/_layouts/images/ittask.png" Name="{FA2AB648-85DE-4068-83E5-F7EEA1BB4DD2}" BaseType="0" FeatureId="00bfea71-a83e-497e-9ba0-7a5c597d0107" ServerTemplate="107" Created="20120711 03:20:07" Modified="20120711 03:33:14" LastDeleted="20120711 03:20:07" Version="23" Direction="none" ThumbnailSize="" WebImageWidth="" WebImageHeight="" Flags="549458112" ItemCount="0" AnonymousPermMask="0" RootFolder="" ReadSecurity="1" WriteSecurity="1" Author="1" EventSinkAssembly="" EventSinkClass="" EventSinkData="" EmailAlias="" WebFullUrl="/SPDev" WebId="a01bc02b-34f9-4391-bbdb-d2a82b9c7768" SendToLocation="" ScopeId="fa7b0ddb-e1c4-4999-bf54-b1912a2e9466" MajorVersionLimit="0" MajorWithMinorVersionsLimit="0" WorkFlowId="" HasUniqueScopes="False" NoThrottleListOperations="False" HasRelatedLists="" AllowDeletion="True" AllowMultiResponses="False" EnableAttachments="True" EnableModeration="False" EnableVersioning="True" HasExternalDataSource="False" Hidden="False" MultipleDataList="False" Ordered="False" ShowUser="True" EnablePeopleSelector="False" EnableResourceSelector="False" EnableMinorVersion="False" RequireCheckout="False" ThrottleListOperations="False" ExcludeFromOfflineClient="False" EnableFolderCreation="False" IrmEnabled="False" IsApplicationList="False" PreserveEmptyValues="False" StrictTypeCoercion="False" EnforceDataValidation="False" MaxItemsPerThrottledOperation="5000" />
                <List DocTemplateUrl="" DefaultViewUrl="/SPDev/Lists/Workflow History/AllItems.aspx" MobileDefaultViewUrl="" ID="{23D8F766-E056-40F0-89FB-5D242CA9E056}" Title="Workflow History" Description="" ImageUrl="/_layouts/images/itwfh.png" Name="{23D8F766-E056-40F0-89FB-5D242CA9E056}" BaseType="0" FeatureId="00bfea71-4ea5-48d4-a4ad-305cf7030140" ServerTemplate="140" Created="20120711 03:20:09" Modified="20120718 12:35:04" LastDeleted="20120711 03:20:09" Version="1" Direction="none" ThumbnailSize="" WebImageWidth="" WebImageHeight="" Flags="536875272" ItemCount="59" AnonymousPermMask="0" RootFolder="" ReadSecurity="1" WriteSecurity="1" Author="1" EventSinkAssembly="" EventSinkClass="" EventSinkData="" EmailAlias="" WebFullUrl="/SPDev" WebId="a01bc02b-34f9-4391-bbdb-d2a82b9c7768" SendToLocation="" ScopeId="fa7b0ddb-e1c4-4999-bf54-b1912a2e9466" MajorVersionLimit="0" MajorWithMinorVersionsLimit="0" WorkFlowId="" HasUniqueScopes="False" NoThrottleListOperations="False" HasRelatedLists="" AllowDeletion="True" AllowMultiResponses="False" EnableAttachments="False" EnableModeration="False" EnableVersioning="False" HasExternalDataSource="False" Hidden="True" MultipleDataList="False" Ordered="False" ShowUser="True" EnablePeopleSelector="False" EnableResourceSelector="False" EnableMinorVersion="False" RequireCheckout="False" ThrottleListOperations="False" ExcludeFromOfflineClient="False" EnableFolderCreation="False" IrmEnabled="False" IsApplicationList="False" PreserveEmptyValues="False" StrictTypeCoercion="False" EnforceDataValidation="False" MaxItemsPerThrottledOperation="5000" />
                <List DocTemplateUrl="" DefaultViewUrl="" MobileDefaultViewUrl="" ID="{857C769E-64A8-4E55-9BB2-76D688A474B2}" Title="Workflows" Description="" ImageUrl="/_layouts/images/itdl.png" Name="{857C769E-64A8-4E55-9BB2-76D688A474B2}" BaseType="1" FeatureId="00bfea71-f600-43f6-a895-40c0de7b0117" ServerTemplate="117" Created="20120711 03:29:45" Modified="20120828 09:43:43" LastDeleted="20120828 09:43:43" Version="5" Direction="none" ThumbnailSize="" WebImageWidth="" WebImageHeight="" Flags="8524168" ItemCount="5" AnonymousPermMask="0" RootFolder="" ReadSecurity="1" WriteSecurity="1" Author="1" EventSinkAssembly="" EventSinkClass="" EventSinkData="" EmailAlias="" WebFullUrl="/SPDev" WebId="a01bc02b-34f9-4391-bbdb-d2a82b9c7768" SendToLocation="" ScopeId="fa7b0ddb-e1c4-4999-bf54-b1912a2e9466" MajorVersionLimit="0" MajorWithMinorVersionsLimit="0" WorkFlowId="" HasUniqueScopes="False" NoThrottleListOperations="False" HasRelatedLists="" AllowDeletion="True" AllowMultiResponses="False" EnableAttachments="False" EnableModeration="False" EnableVersioning="True" HasExternalDataSource="False" Hidden="True" MultipleDataList="False" Ordered="False" ShowUser="True" EnablePeopleSelector="False" EnableResourceSelector="False" EnableMinorVersion="False" RequireCheckout="False" ThrottleListOperations="False" ExcludeFromOfflineClient="False" EnableFolderCreation="True" IrmEnabled="False" IsApplicationList="False" PreserveEmptyValues="False" StrictTypeCoercion="False" EnforceDataValidation="False" MaxItemsPerThrottledOperation="5000" />
            </Lists>
        </GetListCollectionResult>
    </GetListCollectionResponse>
</soap:Body>
.

그래서 내가 옳다면 코드가 있어야합니다 :

      $().SPServices({ 
            operation: "GetListCollection", 
            completefunc: function( xData, Status ) {
                console.log( Status );
                console.log( xData.responseText );
                var userId = $().SPServices.SPGetCurrentUser({
                     fieldName: "ID"
                });

                $( xData.responseXML ).find("Lists > List").each(function() {
                    var $node = $(this);

                    if( userId == $node.attr("Author") ) {
                           //do something clever
                    }

                });
            } 
    });
.

# 2 및 # 3은 spservices spservices 를 사용하는 방법에 대한 많은 예제가 코드화 된 사이트 전체에서 촬영되었습니다....에라이브러리를 사용하고 코드에 대한 특정 질문을 게시하는 방법에 대한 문서를 읽으십시오.

Do somthing like this by adding these line to your view files;

Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/path/to/your/javascript/file');
Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl.'/path/to/css/file');

Also, if you want to add module assets both CSS and JS, you can use the following logic. See how you need to indicate the correct path to getPathOfAlias:

public static function register($file)
{
    $url = Yii::app()->getAssetManager()->publish(
    Yii::getPathOfAlias('application.modules.shop.assets.css'));

    $path = $url . '/' . $file;
    if(strpos($file, 'js') !== false)
        return Yii::app()->clientScript->registerScriptFile($path);
    else if(strpos($file, 'css') !== false)
        return Yii::app()->clientScript->registerCssFile($path);

    return $path;
}

The above code has been taken from GPLed Yii based Webshop app.

You can also add scripts from controller action. Just add this line in an action method then that script will apear only in that view:

Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl . '/js/custom.js', CClientScript::POS_HEAD);

where POS_HEAD tell framework to put script in head section

Allen Qiu MSFT 지원은 내 질문을 위해 재생됩니다 :

이 문제를 해결하려면 누락 된 그룹이나 그룹을 사이트에 추가하십시오.에 이렇게하려면 다음 단계를 수행하십시오.

1. https://yourdomain.sharepoint.com/_layouts/permsetup.aspx .

2. 적절한 섹션 (방문자, 멤버 또는 둘 다)에서 새 그룹 작성 옵션 단추가 선택되어 있는지 확인하십시오.
3. 페이지 하단에 확인을 클릭하십시오.

참조 용 : http://support.microsoft.com/kb/2632494

한 사이트 모음에서 다른 사이트에서 다른 사이트로 파일을 복사 하여이 기사에서 http://sharepointfieldnotes.blogspot.ch/2009/11/how-to-copy-files-across-site.html

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="/news/js/popup.js"></script>

link must input over the first php tag in the view pag

Using bootstrap extension

my css file: themes/bootstrap/css/style.css

my js file: root/js/script.js

at theme/bootstrap/views/layouts/main.php

<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/styles.css" />

<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/script.js"></script>

This was also an easy way to add script and css in main.php

<script src="<?=Yii::app()->theme->baseUrl; ?>/js/bootstrap.min.js"></script>
<link href="<?=Yii::app()->theme->baseUrl; ?>/css/bootstrap.css" rel="stylesheet" type="text/css">

문제가 작동하는지 여부가 아닙니다.문제는 다음 녀석이 귀하의 코드를 읽는 것에 대해 완전히 혼란 스럽다는 것입니다.std::string는 텍스트를 표시하기위한 것입니다.코드를 읽는 사람은 기대할 것입니다.std::vector<char> 의도 을 훨씬 잘 선언하겠습니다.

를 증가시킵니다.

  • In Yii Assets are declared in engine/assets/Appassets.php This make more easier to manage all your css and js files enter image description here
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top