TYPO3 : SimplePoll : show the last

心已入冬 提交于 2020-04-17 21:33:36

问题


currently I'm using simplepoll.uid to show a Poll on the Frontend :

lib.poll = USER
lib.poll {
    userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
    extensionName = Simplepoll
    pluginName = Polllisting
    vendorName = Pixelink
    settings =< plugin.tx_simplepoll.settings
    settings {
        simplepoll.uid = 13 // this is the ID of the Poll to show
    }
    persistence =< plugin.tx_news.persistence
    view =< plugin.tx_news.view 
}

is there a way to show automatically the last poll added to the storagePid instead of simplepoll.uid ?


回答1:


It could be that my solution does not work as there might be no stdWrap support in the extension. Then you should ask the extension author to build in the wrapping (or support him with a pull request).

Requesting the uid from the last created poll should be possible with an SQL query which selects the highest uid.

An SQL query can be done in typoscript with the CONTENT object:

lib.poll {
   settings {
      simplepoll.uid.cObject = CONTENT
      simplepoll.uid.cObject {
         table = tx_poll... // get the exact page name
         select {
            selectFields = uid
            pidInList = ??? // insert storage page of your polls
            orderBy = uid DESC
            max = 1            
         }
         renderObj = TEXT
         renderObj. field = uid
      }
   }
}

You need no WHERE clause to select no deleted and hidden records as these where inserted automatically.

Be aware to create polls in hidden mode otherwise an incomplete poll could be selected.


testing with

<f:cObject typoscriptObjectPath="lib.poll.settings.simplepoll.uid.cObject" />

or

page.1 < lib.poll.settings.simplepoll.uid.cObject
page.1.wrap = <h1>poll = [|]</h1>


来源:https://stackoverflow.com/questions/61157745/typo3-simplepoll-show-the-last

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!