Die TYPO3 Mailingliste - nicht fragen: lesen!
This is a discussion on [TYPO3] First Extension attempt within the typo3-english@lists.netfielders.de forums, part of the TYPO3-Mailinglists: ENGLISH category; Hallo. I trying to make my first extension. When I try and view the page I see this: NO entry ...
|
|||||||
| Registrieren | Hilfe | Benutzerliste | Kalender | Suchen | Heutige Beiträge | Alle Foren als gelesen markieren |
|
#1
|
|||
|
|||
|
Hallo.
I trying to make my first extension. When I try and view the page I see this: NO entry in the $TCA-array for the table "tt_news_related_mm". This means that the function enableFields() is called with an invalid table name as argument. What exactly does this mean? This was the code that made it: $this->query = $this->pi_exec_query("tt_news_related_mm", 0, '`uid_local` =1', '', '', '', ''); What I want to do is just query the database. The table tt_news_related_mm seems to store the related artcile IDs fort t_news articles. I want to get the related ids so that I can display the related articles for a TT_news article in SINGLE view in the right column. _______________________________________________ TYPO3-english mailing list TYPO3-english (AT) lists (DOT) netfielders.de http://lists.netfielders.de/cgi-bin/.../typo3-english |
|
#2
|
|||
|
|||
|
Hi!
Stephen Bungert wrote: > I trying to make my first extension. When I try and view the page I see > this: > > NO entry in the $TCA-array for the table "tt_news_related_mm". This means > that the function enableFields() is called with an invalid table name as > argument. > > What exactly does this mean? > > This was the code that made it: > > $this->query = $this->pi_exec_query("tt_news_related_mm", 0, '`uid_local` > =1', '', '', '', ''); > > What I want to do is just query the database. The table tt_news_related_mm > seems to store the related artcile IDs fort t_news articles. I want to get > the related ids so that I can display the related articles for a TT_news > article in SINGLE view in the right column. Use $GLOBALS['TYPO3_DB'] (class.t3lib_db.php) to query mm table. MM tables are different, they are not defined in TCA and pi_exec_query will not work for them. Btw, you use double quotes while you should use single. Check TYPO3 coding guidelines. -- Dmitry Dulepov TYPO3 core team Web: http://typo3bloke.net/ Skype: callto:liels_bugs "Nothing is impossible. There are only limits to our knowledge" _______________________________________________ TYPO3-english mailing list TYPO3-english (AT) lists (DOT) netfielders.de http://lists.netfielders.de/cgi-bin/.../typo3-english |
|
#3
|
|||
|
|||
|
Ok.
Thanks fort he help. These returns a resource ID: $this->query = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid_foreign', 'tt_news_related_mm', $GLOBALS['TYPO3_DB']->fullQuoteStr('uid_local', 'tt_news_related_mm') . '=1' . $this->newsId, '', '', ''); $this->newsId Is the tt_news ID extracted from GET vars, using t3lib_div::_GET(). Then I do this: $this->result = $GLOBALS['TYPO3_DB']->sql_fetch_row($this->query); This never shows anything. Here is what is in 'tt_news_related_mm'. uid_local uid_foreign sorting tablenames 1 3 1 tt_news 1 5 2 tt_news I'm not very experienced with SQl, but shouldn't I get a result back because ther are two rows in the table where the 'uid_local' = 1 ($this->newsId = 1 for this test) -----Ursprüngliche Nachricht----- Von: typo3-english-bounces (AT) lists (DOT) netfielders.de [mailto:typo3-english-bounces (AT) lists (DOT) netfielders.de] Im Auftrag von Dmitry Dulepov [typo3] Gesendet: Mittwoch, 12. März 2008 14:56 An: typo3-english (AT) lists (DOT) netfielders.de Betreff: Re: [TYPO3] First Extension attempt Hi! Stephen Bungert wrote: > I trying to make my first extension. When I try and view the page I see > this: > > NO entry in the $TCA-array for the table "tt_news_related_mm". This means > that the function enableFields() is called with an invalid table name as > argument. > > What exactly does this mean? > > This was the code that made it: > > $this->query = $this->pi_exec_query("tt_news_related_mm", 0, '`uid_local` > =1', '', '', '', ''); > > What I want to do is just query the database. The table tt_news_related_mm > seems to store the related artcile IDs fort t_news articles. I want to get > the related ids so that I can display the related articles for a TT_news > article in SINGLE view in the right column. Use $GLOBALS['TYPO3_DB'] (class.t3lib_db.php) to query mm table. MM tables are different, they are not defined in TCA and pi_exec_query will not work for them. Btw, you use double quotes while you should use single. Check TYPO3 coding guidelines. -- Dmitry Dulepov TYPO3 core team Web: http://typo3bloke.net/ Skype: callto:liels_bugs "Nothing is impossible. There are only limits to our knowledge" _______________________________________________ TYPO3-english mailing list TYPO3-english (AT) lists (DOT) netfielders.de http://lists.netfielders.de/cgi-bin/.../typo3-english _______________________________________________ TYPO3-english mailing list TYPO3-english (AT) lists (DOT) netfielders.de http://lists.netfielders.de/cgi-bin/.../typo3-english |
|
#4
|
|||
|
|||
|
Hi!
Stephen Bungert wrote: > These returns a resource ID: > $this->query = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid_foreign', > 'tt_news_related_mm', $GLOBALS['TYPO3_DB']->fullQuoteStr('uid_local', > 'tt_news_related_mm') . '=1' . $this->newsId, '', '', ''); > > $this->newsId > > Is the tt_news ID extracted from GET vars, using t3lib_div::_GET(). I'll correct you again You call fullQuoteStr for a simple string but you pass unescaped value of URL parameter, which makes SQL injection possible. Correct ways are:$this->query = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid_foreign', 'tt_news_related_mm', 'uid_local=' . intval($this->newsId), '', '', ''); or: $this->query = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid_foreign', 'tt_news_related_mm', 'uid_local=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->newsId, 'tt_news_related_mm'), '', '', ''); or even: $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid_foreign', 'tt_news_related_mm', 'uid_local=' . intval($this->newsId)); I did not check what uid_local and uid_foreign refer in thius particular case but I think you have two related news items. To get them you can use: $uidList = array(); foreach ($rows as $row) { $uidList[] = $row['uid_foreign']; } $relatedNews = array(); if (count($uidList) > 0) { $relatedNews = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'tt_news', 'uid IN (' . implode(',', $uidList) . ')' . $this->cObj->enableFields('tt_news)); } Or even more sophisticated: $sql = 'SELECT * FROM tt_news WHERE uid IN (SELECT uid_foreign FROM ' . 'tt_news_related_mm WHERE uid_local=' . intval($this->newsId) . ')' . $this->cObj->enableFields('tt_news'); $res = $GLOBALS['TYPO3_DB']->sql_query($sql); $relatedNews = array(); while (false != ($row = $GLOBALS['TYPO3_DB']->sql_fecth_assoc($res))) { $relatedNews[] = $row; } $GLOBALS['TYPO3_DB']->sql_free_result($res); > > Then I do this: > $this->result = $GLOBALS['TYPO3_DB']->sql_fetch_row($this->query); > > This never shows anything. It did not because you have error here: > 'tt_news_related_mm') . '=1' . $this->newsId, '', '', ''); So, if $this->newsId is 5, you get "uid_local=15" in query. -- Dmitry Dulepov TYPO3 core team Web: http://typo3bloke.net/ Skype: callto:liels_bugs "Nothing is impossible. There are only limits to our knowledge" _______________________________________________ TYPO3-english mailing list TYPO3-english (AT) lists (DOT) netfielders.de http://lists.netfielders.de/cgi-bin/.../typo3-english |
|
#5
|
|||
|
|||
|
Thanks for your help! The extension is working out great. I see the result
in th right column. All the related articles are listed, the body text is nicely cropped with .... at the end, I have the timestamp converted. All I hhave to do now is find out how to link the title tot he actual article (in single view). It doesn't seem as daunting now, to start making more extensions when I need them. I have a better undersatnding now about extensions, how they work, and the TYPO3 API. -----Ursprüngliche Nachricht----- Von: typo3-english-bounces (AT) lists (DOT) netfielders.de [mailto:typo3-english-bounces (AT) lists (DOT) netfielders.de] Im Auftrag von Dmitry Dulepov [typo3] Gesendet: Mittwoch, 12. März 2008 16:56 An: typo3-english (AT) lists (DOT) netfielders.de Betreff: Re: [TYPO3] First Extension attempt Hi! Stephen Bungert wrote: > These returns a resource ID: > $this->query = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid_foreign', > 'tt_news_related_mm', $GLOBALS['TYPO3_DB']->fullQuoteStr('uid_local', > 'tt_news_related_mm') . '=1' . $this->newsId, '', '', ''); > > $this->newsId > > Is the tt_news ID extracted from GET vars, using t3lib_div::_GET(). I'll correct you again You call fullQuoteStr for a simple string but youpass unescaped value of URL parameter, which makes SQL injection possible. Correct ways are: $this->query = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid_foreign', 'tt_news_related_mm', 'uid_local=' . intval($this->newsId), '', '', ''); or: $this->query = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid_foreign', 'tt_news_related_mm', 'uid_local=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->newsId, 'tt_news_related_mm'), '', '', ''); or even: $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid_foreign', 'tt_news_related_mm', 'uid_local=' . intval($this->newsId)); I did not check what uid_local and uid_foreign refer in thius particular case but I think you have two related news items. To get them you can use: $uidList = array(); foreach ($rows as $row) { $uidList[] = $row['uid_foreign']; } $relatedNews = array(); if (count($uidList) > 0) { $relatedNews = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'tt_news', 'uid IN (' . implode(',', $uidList) . ')' . $this->cObj->enableFields('tt_news)); } Or even more sophisticated: $sql = 'SELECT * FROM tt_news WHERE uid IN (SELECT uid_foreign FROM ' . 'tt_news_related_mm WHERE uid_local=' . intval($this->newsId) . ')' . $this->cObj->enableFields('tt_news'); $res = $GLOBALS['TYPO3_DB']->sql_query($sql); $relatedNews = array(); while (false != ($row = $GLOBALS['TYPO3_DB']->sql_fecth_assoc($res))) { $relatedNews[] = $row; } $GLOBALS['TYPO3_DB']->sql_free_result($res); > > Then I do this: > $this->result = $GLOBALS['TYPO3_DB']->sql_fetch_row($this->query); > > This never shows anything. It did not because you have error here: > 'tt_news_related_mm') . '=1' . $this->newsId, '', '', ''); So, if $this->newsId is 5, you get "uid_local=15" in query. -- Dmitry Dulepov TYPO3 core team Web: http://typo3bloke.net/ Skype: callto:liels_bugs "Nothing is impossible. There are only limits to our knowledge" _______________________________________________ TYPO3-english mailing list TYPO3-english (AT) lists (DOT) netfielders.de http://lists.netfielders.de/cgi-bin/.../typo3-english _______________________________________________ TYPO3-english mailing list TYPO3-english (AT) lists (DOT) netfielders.de http://lists.netfielders.de/cgi-bin/.../typo3-english |
|
#6
|
|||
|
|||
|
Hi!
Stephen Bungert wrote: > All the related articles are listed, the body text is nicely cropped with > ... at the end, I have the timestamp converted. All I hhave to do now is > find out how to link the title tot he actual article (in single view). $conf = array( 'parameter' => $this->conf['ttnewsSinglePid'], 'additionalParams' => '&tx_ttnews[tt_news]=' . $newsUid, 'useCacheHash' => true, ); $url = $this->cObj->typoLink_URL($conf); You need a page id with tt_news single view in $this->conf['ttnewsSinglePid']. -- Dmitry Dulepov TYPO3 core team Web: http://typo3bloke.net/ Skype: callto:liels_bugs "Nothing is impossible. There are only limits to our knowledge" _______________________________________________ TYPO3-english mailing list TYPO3-english (AT) lists (DOT) netfielders.de http://lists.netfielders.de/cgi-bin/.../typo3-english |
|
#7
|
|||
|
|||
|
Hallo.
I tried to use that: for ($index = 0; $index < $loopCount; $index ++) { $conf = array('parameter' => $this->conf['ttnewsSinglePid'], 'additionalParams' => '&tx_ttnews[tt_news]=' .. $this->result[$index], 'useCacheHash' => true,); $url = $this->cObj->typoLink_URL($conf); $content .= '<div id="sbArticle"> <p id="sbArtTitle"><a href="' . $url .. '" title=" View this article (' . $this->matchingResult[$index]['title'] . ')">' . $this->matchingResult[$index]['title'] . '</a> <span id="sbArtTimeStamp">' . $this->matchingResult[$index]['datetime'] . '</span></p> <p id="sbArtSummary">' . $this->matchingResult[$index]['bodytext'] . ' <a class="articleLink">Read More</a></p> </div> </div>'; } But it always sets &tx_ttnews[tt_news]= to 1 (this ist he same as the one I'm currently looking at, so all links just go tot he current one SINGLE article). Have you, or anyone else an idea about what I did wrong? -----Ursprüngliche Nachricht----- Von: typo3-english-bounces (AT) lists (DOT) netfielders.de [mailto:typo3-english-bounces (AT) lists (DOT) netfielders.de] Im Auftrag von Dmitry Dulepov [typo3] Gesendet: Mittwoch, 12. März 2008 18:59 An: typo3-english (AT) lists (DOT) netfielders.de Betreff: Re: [TYPO3] First Extension attempt Hi! Stephen Bungert wrote: > All the related articles are listed, the body text is nicely cropped with > ... at the end, I have the timestamp converted. All I hhave to do now is > find out how to link the title tot he actual article (in single view). $conf = array( 'parameter' => $this->conf['ttnewsSinglePid'], 'additionalParams' => '&tx_ttnews[tt_news]=' . $newsUid, 'useCacheHash' => true, ); $url = $this->cObj->typoLink_URL($conf); You need a page id with tt_news single view in $this->conf['ttnewsSinglePid']. -- Dmitry Dulepov TYPO3 core team Web: http://typo3bloke.net/ Skype: callto:liels_bugs "Nothing is impossible. There are only limits to our knowledge" _______________________________________________ TYPO3-english mailing list TYPO3-english (AT) lists (DOT) netfielders.de http://lists.netfielders.de/cgi-bin/.../typo3-english _______________________________________________ TYPO3-english mailing list TYPO3-english (AT) lists (DOT) netfielders.de http://lists.netfielders.de/cgi-bin/.../typo3-english |
|
#8
|
|||
|
|||
|
Hmm..
'parameter' => $this->conf['ttnewsSinglePid'], replacing this with the actual single page pid works: 'parameter' => 14, Then it functions again. The contents of $this->conf is just: userFunc : tx_relatedttnews_pi1->main, there is no ttnewsSinglePid -----Ursprüngliche Nachricht----- Von: typo3-english-bounces (AT) lists (DOT) netfielders.de [mailto:typo3-english-bounces (AT) lists (DOT) netfielders.de] Im Auftrag von Dmitry Dulepov [typo3] Gesendet: Mittwoch, 12. März 2008 18:59 An: typo3-english (AT) lists (DOT) netfielders.de Betreff: Re: [TYPO3] First Extension attempt Hi! Stephen Bungert wrote: > All the related articles are listed, the body text is nicely cropped with > ... at the end, I have the timestamp converted. All I hhave to do now is > find out how to link the title tot he actual article (in single view). $conf = array( 'parameter' => $this->conf['ttnewsSinglePid'], 'additionalParams' => '&tx_ttnews[tt_news]=' . $newsUid, 'useCacheHash' => true, ); $url = $this->cObj->typoLink_URL($conf); You need a page id with tt_news single view in $this->conf['ttnewsSinglePid']. -- Dmitry Dulepov TYPO3 core team Web: http://typo3bloke.net/ Skype: callto:liels_bugs "Nothing is impossible. There are only limits to our knowledge" _______________________________________________ TYPO3-english mailing list TYPO3-english (AT) lists (DOT) netfielders.de http://lists.netfielders.de/cgi-bin/.../typo3-english _______________________________________________ TYPO3-english mailing list TYPO3-english (AT) lists (DOT) netfielders.de http://lists.netfielders.de/cgi-bin/.../typo3-english |
|
#9
|
|||
|
|||
|
Hi!
Stephen Bungert wrote: > Hmm.. > 'parameter' => $this->conf['ttnewsSinglePid'], replacing this with the > actual single page pid works: > 'parameter' => 14, Learn to read! I wrote in my post: > You need a page id with tt_news single view in $this->conf['ttnewsSinglePid']. -- Dmitry Dulepov TYPO3 core team Web: http://typo3bloke.net/ Skype: callto:liels_bugs "Nothing is impossible. There are only limits to our knowledge" _______________________________________________ TYPO3-english mailing list TYPO3-english (AT) lists (DOT) netfielders.de http://lists.netfielders.de/cgi-bin/.../typo3-english |
|
#10
|
|||
|
|||
|
Ok, thanks!
I have it set up now. I set ttnewsSinglePid through typoscript in the backend. Thanks again. -----Ursprüngliche Nachricht----- Von: typo3-english-bounces (AT) lists (DOT) netfielders.de [mailto:typo3-english-bounces (AT) lists (DOT) netfielders.de] Im Auftrag von Dmitry Dulepov [typo3] Gesendet: Donnerstag, 13. März 2008 11:58 An: typo3-english (AT) lists (DOT) netfielders.de Betreff: Re: [TYPO3] First Extension attempt Hi! Stephen Bungert wrote: > Hmm.. > 'parameter' => $this->conf['ttnewsSinglePid'], replacing this with the > actual single page pid works: > 'parameter' => 14, Learn to read! I wrote in my post: > You need a page id with tt_news single view in $this->conf['ttnewsSinglePid']. -- Dmitry Dulepov TYPO3 core team Web: http://typo3bloke.net/ Skype: callto:liels_bugs "Nothing is impossible. There are only limits to our knowledge" _______________________________________________ TYPO3-english mailing list TYPO3-english (AT) lists (DOT) netfielders.de http://lists.netfielders.de/cgi-bin/.../typo3-english _______________________________________________ TYPO3-english mailing list TYPO3-english (AT) lists (DOT) netfielders.de http://lists.netfielders.de/cgi-bin/.../typo3-english |
| Themen-Optionen | Thema durchsuchen |
| Ansicht | Thema bewerten |
|
|
|
||||
| Thema | Autor | Forum | Antworten | Letzter Beitrag |
| [TYPO3-german] "Attempt to insert record on page '[root-level]'(0)" mal anders | Matthias Stuebner | typo3-german@lists.netfielders.de | 0 | 24.12.2007 22:17 |
| [TYPO3-german] Extension in andere Extension einbinden | Julian Lamberty | typo3-german@lists.netfielders.de | 1 | 20.11.2007 16:10 |
| [TYPO3] white screen follows non-admin edit attempt | David Banning | typo3-english@lists.netfielders.de | 0 | 01.10.2007 21:02 |
| [TYPO3] [HTMLArea::initIframe]: Failed attempt at loading | Gunnar Jonsson | typo3-english@lists.netfielders.de | 0 | 26.09.2007 22:12 |
| [TYPO3] company_database: problems with display and categories -2nd attempt | Gunda | typo3-english@lists.netfielders.de | 0 | 02.02.2007 13:00 |