これは簡単だと思いましたが、難しいことがわかりました。私がやろうとしているのは、オブジェクトの値を置き換えてから、変更された文字列を出力することだけです。ちなみに、これはJoomla内にあります。それは重要ではありません。コード内のすべてのJHTML/およびJURiのものを説明するだけです。
私が試しているコードは...
<?php
// Display the child select box.
if (isset($this->containers) && count($this->containers)):
$items = str_replace("Your Favorite Places", "Browse By Region", $this->containers);
echo JHtml::_('select.genericlist', $items, 'finder-containers','onchange="document.location=this.value; return false;"', 'link', 'indented', JUri::getInstance()->toString(array('path')));
endif;
?>
だから私のstr_replace
ラインは私が問題を抱えているところです。$this->containers
状態の配列であり、他のものがドロップダウンボックスにエコーアウトします。最後の行にエコーする前に置換を試みましたが、「YourFavoritePlaces」という言葉がまだ残っています。これをループなどに入れる必要がありforeach
ますか?
これが部分的なprint_rです(実際、置き換えたい文字列が含まれています。カテゴリタイトル=>お気に入りの場所)
Array (
[0] => stdClass Object (
[category_id] => 1
[title] => Gallery
[alias] => gallery
[slug] => 1:gallery
[level] => 0
[my_items] => 0
[url] => index.php?option=com_gallery&view=images&category_id=1
[route] => index.php?option=com_gallery&view=images&category_id=1:gallery&Itemid=1766
[link] => /your-favorite-places/categories/gallery.html
[indented] => Gallery
)
[1] => stdClass Object (
[category_id] => 164
[title] => Your Favorite Places
[alias] => your-favorite-places
[slug] => 164:gallery/your-favorite-places
[level] => 1
[my_items] => 0
[url] => index.php?option=com_gallery&view=images&category_id=164
[route] => index.php?option=com_gallery&view=images&category_id=164:gallery/your-favorite-places&Itemid=3711
[link] => /your-favorite-places/gallery.html
[indented] => Your Favorite Places
)
[2] => stdClass Object (
[category_id] => 87
[title] => North America
[alias] => north-america
[slug] => 87:gallery/your-favorite-places/north-america
[level] => 2
[my_items] => 0
[url] => index.php?option=com_gallery&view=images&category_id=87
[route] => index.php?option=com_gallery&view=images&category_id=87:gallery/your-favorite-places/north-america&Itemid=1775
[link] => /your-favorite-places/north-america.html
[indented] => North America
)