Skocz do zawartości
"Idzie nowe..." - o zmianach i nie tylko ×
Przeniesienie zakupów z IPS Marketplace / Moving bought items from IPS Marketplace ×

Undefined Constant...


Przejdź do rozwiązania Rozwiązane przez Weak.,

Rekomendowane odpowiedzi

Opublikowano (edytowane)

Hej. Nie wiem czy coś źle robię :D   

 

protected function _market()
    {
        $marketCars = \IPS\Db::i()->select( '*', 'auctions', array('auction_type = 1') );
   $marketItems = \IPS\Db::i()->select( '*', 'auctions', array('auction_type = 2') );
   $marketDoors = \IPS\Db::i()->select( '*', 'auctions', array('auction_type = 3') );
        /* Return */
        return \IPS\Theme::i()->getTemplate('character')->market($marketItems, $marketCars, $marketDoors );
    }

   Poproszę o pomoc! :)

Edytowane przez BooyaK
Opublikowano

Twój kod wyrzuca Ci QUERY, dodaj ->first(); do każdego

np.

$marketCars = \IPS\Db::i()->select( '*', 'auctions', array('auction_type = 1') )->first();

I zamiast tworzyć selecta, stwórz pętle.

$results = [];
foreach( \IPS\Db::i()->select( '*', 'auctions' ) as $row ) {
	$results[] = $row;
}

return \IPS\Theme::i()->getTemplate('character')->market($results);

 

  • Lubię to 1
Opublikowano

Posiadam taki kod: 

         {{if !marketCars}}
          	Brak wystawionych ofert
          {{else}}
          {{foreach $marketCars as $row}}
          <li class="cForumRow ipsDataItem ipsDataItem_responsivePhoto  ipsClearfix">
            <div class="ipsDataItem_main" style="vertical-align: middle">
                <h4 class="ipsDataItem_title ipsType_large ipsType_break">
                  {{if $row['auction_priority'] == 1}}
                  <span class="ipsBadge ipsBadge_large ipsBadge_intermediary">Sponsorowane</span>  
                  {{endif}}
                  <a href="index.php?/character/&tab=market&viewMarket={$row['auction_id']}">{$row['name']}</a>
                </h4>
            </div>
           <ul class="ipsDataItem_lastPoster ipsDataItem_withPhoto" style="text-align: center">
              <li class="ipsType_success">
                 <span class="ipsBadge ipsBadge_medium ipsBadge_positive">
                   <strong><i class="fa fa-handshake-o"></i> &nbsp; <i class="fa fa-usd" style="font-size: 95%"></i>{$row['auction_buynow']}</strong>
                </span>
              </li>
              {{if $row['auction_startprice'] == 0}}
               <li class="ipsType_light">
              	 -
              </li>
              {{else}}
              <li class="ipsType_light">
               <span class="ipsBadge ipsBadge_medium ipsBadge_neutral">
                <strong><i class="fa fa-gavel"></i> &nbsp; <i class="fa fa-usd" style="font-size: 95%"></i>{$row['auction_startprice']}</strong>
                </span>
              </li>
               {{endif}}
            </ul>
            <ul class="ipsDataItem_lastPoster ipsDataItem_withPhoto" style="text-align: center">
              <li>
                <strong>{$row['auction_owner']}</strong>
              </li>
              <li>
                {datetime="$row['auction_date']"}
              </li>
            </ul>
          </li>
        {{endforeach}}
           {{endif}}
        </div>
      
    </ol>
  </div>

 

Chciałbym aby $row pobierało dane z MYSQL.. ucze sie dopiero tego wszystkiego więc może robie coś źle :c

Opublikowano
25 minut temu, DawPi napisał(a):

Napisałeś w tytule:

To teraz wyjaśnij gdzie i jak się to wyświetla. To nie ma związku z tym $row.

 

Ahh.. tak, wybacz - zapomniałem :) 

Error: Undefined constant "IPS\Theme\marketCars" in /var/www/html/forum/system/Theme/Theme.php(885) : eval()'d code:2865
Stack trace:
#0 /var/www/html/forum/system/Theme/SandboxedTemplate.php(61): IPS\Theme\class_game_front_character->tabMarket()
#1 /var/www/html/forum/applications/game/modules/front/character/character.php(488): IPS\Theme\_SandboxedTemplate->__call()
#2 [internal function]: IPS\game\modules\front\character\_character->_market()
#3 /var/www/html/forum/applications/game/modules/front/character/character.php(47): call_user_func()
#4 /var/www/html/forum/system/Dispatcher/Controller.php(118): IPS\game\modules\front\character\_character->manage()
#5 /var/www/html/forum/applications/game/modules/front/character/character.php(26): IPS\Dispatcher\_Controller->execute()
#6 /var/www/html/forum/system/Dispatcher/Dispatcher.php(153): IPS\game\modules\front\character\_character->execute()
#7 /var/www/html/forum/index.php(13): IPS\_Dispatcher->run()
#8 {main}

 

Opublikowano
34 minuty temu, Weak. napisał(a):

{{if !marketCars}}?

Powinno być: 

{{if !$marketCars}}

Teraz mam takie coś: 

 

UnderflowException:  (0)
#0 /var/www/html/forum/applications/game/modules/front/character/character.php(492): IPS\Db\_Select->first()
#1 [internal function]: IPS\game\modules\front\character\_character->_market()
#2 /var/www/html/forum/applications/game/modules/front/character/character.php(47): call_user_func()
#3 /var/www/html/forum/system/Dispatcher/Controller.php(118): IPS\game\modules\front\character\_character->manage()
#4 /var/www/html/forum/applications/game/modules/front/character/character.php(26): IPS\Dispatcher\_Controller->execute()
#5 /var/www/html/forum/system/Dispatcher/Dispatcher.php(153): IPS\game\modules\front\character\_character->execute()
#6 /var/www/html/forum/index.php(13): IPS\_Dispatcher->run()
#7 {main}

 

Opublikowano
<h2 class="ipsType_sectionTitle ipsType_reset cForumTitle">Market / W trakcie budowy.</h2>
<hr class="ipsHr"> 
{{if \IPS\Request::i()->action == 'makeOffert' }}
	Tutaj będziesz mógł dodać ofertę.
{{else}}
<div class="ipsTabs saTabs ipsClearfix" id="ticketsTabs" data-ipstabbar="" data-ipstabbar-contentarea="#ticketsTabContent"> 
  <ul role="tablist" class="ipsList_reset" style="float: left">	
    <a class="ipsTabs_item saTabs_item ipsTabs_activeItem" id="cat_items" role="tab" aria-selected="true">
      <span class="saTabs_count" data-action="quickToggleCount"> <i class="fa fa-phone"></i></span>
      Przedmioty
    </a>
    <a class="ipsTabs_item saTabs_item" id="cat_cars" role="tab">
      <span class="saTabs_count" data-action="quickToggleCount"> <i class="fa fa-car"></i></span>
      Pojazdy
    </a>
    <a class="ipsTabs_item saTabs_item" id="cat_doors" role="tab">
      <span class="saTabs_count" data-action="quickToggleCount"><i class="fa fa-home"></i></span>
      Posiadłości
    </a>	
  </ul>
  <a href="index.php?/character/&tab=market&action=makeOffert" data-ipsdialog-title="Dodawanie oferty" style="float: right; padding-top: 10px; padding-right: 10px;">
    <span class="ipsBadge ipsBadge_large ipsBadge_intermediary">
      <i class="fa fa-plus"></i> Dodaj oferte
    </span>
  </a>
</div>
<section id="ticketsTabContent">
  <div id="ipsTabs_ticketsTabs_cat_items_panel" class="ipsTabs_panel" aria-labelledby="cat_items" aria-hidden="false" style="display: block;" animating="false">		
    <ol class="ipsBox ipsDataList ipsDataList_large ipsDataList_zebra ipsAreaBackground_reset cForumList" data-role="market" style="border-top: 0;">
      
        <div style="padding: 25px;">	
           {{foreach $marketItems as $row}}
          <li class="cForumRow ipsDataItem ipsDataItem_responsivePhoto  ipsClearfix">
            <div class="ipsDataItem_main" style="vertical-align: middle">
                <h4 class="ipsDataItem_title ipsType_large ipsType_break">
                  {{if $row['auction_priority'] == 1}}
                  <span class="ipsBadge ipsBadge_large ipsBadge_intermediary">Sponsorowane</span>  
                  {{endif}}
                  <a href="index.php?/character/&tab=market&viewMarketItem={$row['auction_id']}">{$row['auction_uid']}</a>
                </h4>
            </div>
           <ul class="ipsDataItem_lastPoster ipsDataItem_withPhoto" style="text-align: center">
              <li class="ipsType_success">
                 <span class="ipsBadge ipsBadge_medium ipsBadge_positive">
                <strong><i class="fa fa-handshake-o"></i> &nbsp; <i class="fa fa-usd" style="font-size: 95%"></i>{$row['auction_buynow']}</strong>
                </span>
              </li>
              {{if $row['auction_startprice'] == 0}}
               <li class="ipsType_light">
              	 -
              </li>
              {{else}}
              <li class="ipsType_light">
               <span class="ipsBadge ipsBadge_medium ipsBadge_neutral">
                <strong><i class="fa fa-gavel"></i> &nbsp; <i class="fa fa-usd" style="font-size: 95%"></i>{$row['auction_startprice']}</strong>
                </span>
              </li>
               {{endif}}
            </ul>
            <ul class="ipsDataItem_lastPoster ipsDataItem_withPhoto" style="text-align: center">
              <li>
                <strong>{$row['auction_owner']}</strong>
              </li>
              <li>
                {datetime="$row['auction_date']"}
              </li>
            </ul>
          </li>
        {{endforeach}}
        </div>
      
    </ol>
  </div>
  <div id="ipsTabs_ticketsTabs_cat_cars_panel" class="ipsTabs_panel" aria-labelledby="cat_cars" aria-hidden="false" style="display: block;" animating="false">
    <ol class="ipsBox ipsDataList ipsDataList_large ipsDataList_zebra ipsAreaBackground_reset cForumList" data-role="market" style="border-top: 0;">
      
        <div style="padding: 25px;">
{{if !$marketCars}}

          	Brak wystawionych ofert
          {{else}}
          {{foreach $marketCars as $row}}
          <li class="cForumRow ipsDataItem ipsDataItem_responsivePhoto  ipsClearfix">
            <div class="ipsDataItem_main" style="vertical-align: middle">
                <h4 class="ipsDataItem_title ipsType_large ipsType_break">
                  {{if $row['auction_priority'] == 1}}
                  <span class="ipsBadge ipsBadge_large ipsBadge_intermediary">Sponsorowane</span>  
                  {{endif}}
                  <a href="index.php?/character/&tab=market&viewMarket={$row['auction_id']}">{$row['name']}</a>
                </h4>
            </div>
           <ul class="ipsDataItem_lastPoster ipsDataItem_withPhoto" style="text-align: center">
              <li class="ipsType_success">
                 <span class="ipsBadge ipsBadge_medium ipsBadge_positive">
                   <strong><i class="fa fa-handshake-o"></i> &nbsp; <i class="fa fa-usd" style="font-size: 95%"></i>{$row['auction_buynow']}</strong>
                </span>
              </li>
              {{if $row['auction_startprice'] == 0}}
               <li class="ipsType_light">
              	 -
              </li>
              {{else}}
              <li class="ipsType_light">
               <span class="ipsBadge ipsBadge_medium ipsBadge_neutral">
                <strong><i class="fa fa-gavel"></i> &nbsp; <i class="fa fa-usd" style="font-size: 95%"></i>{$row['auction_startprice']}</strong>
                </span>
              </li>
               {{endif}}
            </ul>
            <ul class="ipsDataItem_lastPoster ipsDataItem_withPhoto" style="text-align: center">
              <li>
                <strong>{$row['auction_owner']}</strong>
              </li>
              <li>
                {datetime="$row['auction_date']"}
              </li>
            </ul>
          </li>
        {{endforeach}}
           {{endif}}
        </div>
      
    </ol>
  </div>
  <div id="ipsTabs_ticketsTabs_cat_doors_panel" class="ipsTabs_panel" aria-labelledby="cat_doors" aria-hidden="false" style="display: block;" animating="false">
    <ol class="ipsBox ipsDataList ipsDataList_large ipsDataList_zebra ipsAreaBackground_reset cForumList" data-role="market" style="border-top: 0;">
      
         <div style="padding: 25px;">
          {{if !$marketDoors}}
          	Brak wystawionych ofert
          {{else}}
          {{foreach $marketDoors as $row}}
          <li class="cForumRow ipsDataItem ipsDataItem_responsivePhoto  ipsClearfix">
            <div class="ipsDataItem_main" style="vertical-align: middle">
                <h4 class="ipsDataItem_title ipsType_large ipsType_break">
                  {{if $row['auction_priority'] == 1}}
                  <span class="ipsBadge ipsBadge_large ipsBadge_intermediary">Sponsorowane</span>  
                  {{endif}}
                  <a href="index.php?/character/&tab=market&viewMarket={$row['auction_id']}">{$row['nazwa']}</a>
                </h4>
            </div>
            <ul class="ipsDataItem_lastPoster ipsDataItem_withPhoto" style="text-align: center">
              <li class="ipsType_success">
                 <span class="ipsBadge ipsBadge_medium ipsBadge_positive">
                <strong><i class="fa fa-handshake-o"></i> &nbsp; <i class="fa fa-usd" style="font-size: 95%"></i>{$row['auction_buynow']}</strong>
                </span>
              </li>
              {{if $row['auction_startprice'] == 0}}
               <li class="ipsType_light">
              	 -
              </li>
              {{else}}
              <li class="ipsType_light">
               <span class="ipsBadge ipsBadge_medium ipsBadge_neutral">
                <strong><i class="fa fa-gavel"></i> &nbsp; <i class="fa fa-usd" style="font-size: 95%"></i>{$row['auction_startprice']}</strong>
                </span>
              </li>
               {{endif}}
            </ul>
            <ul class="ipsDataItem_lastPoster ipsDataItem_withPhoto" style="text-align: center">
              <li>
                <strong>{$row['auction_owner']}</strong>
              </li>
              <li>
                {datetime="$row['auction_date']"}
              </li>
            </ul>
          </li>
        {{endforeach}}
           {{endif}}
        </div>
      
    </ol>
  </div>
</section>

{{endif}}

 

PHP:

	protected function _market()
	{
	$marketCars = \IPS\Db::i()->select( '*', 'auctions', array('auction_type = 1') )->first();
   $marketItems = \IPS\Db::i()->select( '*', 'auctions', array('auction_type = 2') );
   $marketDoors = \IPS\Db::i()->select( '*', 'auctions', array('auction_type = 3') );
   $results = [];
foreach( \IPS\Db::i()->select( '*', 'auctions' ) as $row ) {
	$results[] = $row;
}
		/* Return */
		return \IPS\Theme::i()->getTemplate('character')->tabMarket($marketItems, $marketCars, $marketDoors );
	}

 

  • Rozwiązanie
Opublikowano
protected function _market()
{
	$results = [];
	foreach( \IPS\Db::i()->select( '*', 'auctions' ) as $row ) {
		$results[] = $row;
	}
	
	return \IPS\Theme::i()->getTemplate('character')->tabMarket($results);
}

I na samej górze w stylu dodaj:

<ips:template parameters="$results" />

 

 

Resztę kodu zostawię bez komentarza.

  • Dziękuję 1
Opublikowano
12 minut temu, Weak. napisał(a):
protected function _market()
{
	$results = [];
	foreach( \IPS\Db::i()->select( '*', 'auctions' ) as $row ) {
		$results[] = $row;
	}
	
	return \IPS\Theme::i()->getTemplate('character')->tabMarket($results);
}

I na samej górze w stylu dodaj:

<ips:template parameters="$results" />

 

 

Resztę kodu zostawię bez komentarza.

 Dziękuję za pomoc, czy jesteś w stanie pomóc mi jeszcze z czymś? 

Gość
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...

Powiadomienie o plikach cookie

Umieściliśmy na Twoim urządzeniu pliki cookie, aby pomóc Ci usprawnić przeglądanie strony. Możesz dostosować ustawienia plików cookie, w przeciwnym wypadku zakładamy, że wyrażasz na to zgodę.