2017-04-19 82 views
1

我正在爲我的新安裝Mura創建一些自定義頁面佈局(我是Mura的新手,但我們正在使用這個在我的工作,所以我正在學習,因爲我去),但我' m需要對頁面主體提供一些幫助。繼與村來了一個默認的佈局,下面的代碼是輸出頁面的主體:Mura CMS - 我有什麼選擇來顯示身體內容?

#$.dspBody(
body=$.content('body') 
, pageTitle=pageTitle 
, crumbList=0 
, showMetaImage=0 
)# 

當關聯的圖像被分配到頁面,這個圖顯示了,當我擁有的頁面的索引(一例如文件夾),這很棒。但是,當您查看頁面時,它也出現在主體的頂部。

看看上面的代碼,是否有另一個屬性,我可以放在那裏刪除相關的圖像?如果是這樣,我在這裏有什麼可用的屬性?我似乎無法在Mura網站上找到有關此位代碼的任何文檔。

按照要求,對於佈局問題

<cfoutput> 
    <cfinclude template="inc/html_head.cfm" /> 
    <body id="#$.getTopID()#" class="depth-#$.content('depth')# #$.createCSSHook($.content('menuTitle'))#"> 
     <div class="coverImageWrapper"> 
      <div class="coverImage"> 
       <cfinclude template="inc/header.cfm" /> 
       <cfinclude template="inc/departmentName_socialMedia.cfm" /> 
       <cfinclude template="inc/topNav.cfm" /> 
      </div> 
     </div> 
     <div class="secondaryPageWrapper"> 
      <div class="container"> 
       <div class="row"> 
        <div class="col-md-8 mainCol"> 

         <cfinclude template="inc/breadcrumb.cfm" /> 
         <cfset pageTitle = $.content('type') neq 'Page' ? $.content('title') : ''> 
         #$.dspObjects(2)# 
         #$.dspBody(
         body=$.content('body') 
         , pageTitle=pageTitle 
         , crumbList=0 
         , showMetaImage=0 
         )# 
        </div> 
        <aside class="col-md-4 sideCol"> 
         #$.dspObjects(3)# 
        </aside> 
       </div> 
      </div> 
     </div> 
     <cfinclude template="inc/department_footer.cfm" /> 
     <cfinclude template="inc/footer.cfm" /> 
     <cfinclude template="inc/html_foot.cfm" /> 
    </body> 
</cfoutput> 

enter image description here

+0

我們需要看到不止於此代碼。這也有助於查看您的問題的屏幕截圖。在您分享的特定代碼段中,「showMetaImage」屬性控制是否顯示相關圖像。設置爲「0」不會顯示圖像。因此,代碼中必須顯示其他內容才能顯示圖像。什麼模板分配給您的文件夾頁面?那個頁面的'body'中包含了什麼(是那裏的圖像)? –

+0

沒有比這更多的代碼。這是默認的mura頁面佈局的直接。這就是用於輸出正文的所有內容, 圖像不在文檔的正文中,也就是說,它不在可編輯內容區域中。圖像是在頁面標題之後和可編輯內容之前出現的第一個。 我已經添加了佈局中的所有代碼。 – JesseEarley

+0

你可以分享問題的截圖嗎?還是我們可以點擊的頁面?已添加 –

回答

3

@JesseEarley整個代碼,

首先,請http://docs.getmura.com/v7/theme-developers/看看我們的在線主題開發人員指南。我相信你會覺得很有用。

至於您的相關圖片問題,如果您使用的是最新版本的Mura,並使用默認主題MuraBootstrap3,那麼您會發現一個標有content-types的目錄。在那裏,您應該看到標有page的另一個目錄,其文件標記爲index.cfm。這個文件是控制主體視圖的東西。在該文件中,有專門用來輸出相關圖像的代碼段:

<!--- Primary Associated Image ---> 
    <cfif $.content().hasImage(usePlaceholder=false)> 
     <cfscript> 
      img = $.content().getImageURL(
       size = 'carouselimage' // small, medium, large, custom, or any other pre-defined image size 
       ,complete = false // set to true to include the entire URL, not just the absolute path (default) 
      ); 
     </cfscript> 
     <div class="mura-asset"> 
      <a class="mura-meta-image-link" href="#$.content().getImageURL()#" title="#esapiEncode('html_attr', $.content('title'))#" rel="shadowbox[body]"> 
       <img class-"mura-meta-image carouselimage" src="#img#" alt="#esapiEncode('html_attr', $.content('title'))#"> 
      </a> 
     </div> 
    </cfif> 
<!--- /Primary Associated Image ---> 

這就是你可以輸入你的定製邏輯,或者乾脆刪除它,如果你想。

澄清

$.dspBody()呼叫觸發requirements.mura.content.contentRenderer.cfc:dspBody()下的方法。在該方法中,Mura會查看是否有任何覆蓋指定內容類型的呈現(例如,PageFolderCalendar等),並且有多種方法可以覆蓋輸出。例如,在您的主題的eventHandler.cfc中,您可以使用一種名爲onPageDefaultBodyRender()的方法,如果它返回一個字符串,則將使用該字符串。以類似的方式,Mura將掃描主題中的特定目錄,如content_types,如果找到,則會掃描內容類型,如page,然後使用index.cfm作爲主體的呈現。這正是在這種情況下發生的事情。

正如我在下面的註釋中所述,我目前正在編寫文檔,並將以更清晰,更希望更清晰的格式顯示此信息。現在,您可能需要查看我的演示文稿http://docs.getmura.com/v7/videos/webinars/super-fast-app-dev-with-mura-7/,以便在撰寫新文檔時快速瞭解其中的一些內容。

此外,作爲替代,您可以暫時刪除content_types目錄,或將其重命名爲其他內容,以查看dspBody()如何在不覆蓋的情況下呈現您的內容。

乾杯, 史蒂夫

+1

'dspBody()'方法不再用於Mura 7? –

+0

我在這裏看到dspBody()方法:http://docs.getmura.com/v7/theme-developers/creating-layout-templates/template-variables-helper-methods/dspbody/,它顯示設置' showMetaImage'爲false不應該顯示相關的圖像,那麼爲什麼這似乎對Mura 7沒有影響? – JesseEarley

+0

'dspBody()'是絕對使用的,實際上會觸發包含的文件。使用'content_types/page/index.cfm'是一種覆蓋技術。其中一些內容在http://docs.getmura.com/v7/videos/webinars/super-fast-app-dev-with-mura-7/上的演示中進行了介紹。我目前正在開發Mura開發人員指南,這種信息將在更深層次上進行介紹。 –