ozzy47 Posted December 17, 2011 Share Posted December 17, 2011 Please be easy with me as I am new to this, so I will try to explain as best as I can. In my php file I have used this: $vbulletin->templatecache['navbar']= preg_replace( $search[1] = '#(<li>|<li\s*class="selected">)*<a\s*class="navtab"\s*href="search\.php\?\'\s*\.\s*\$session\[\'sessionurl\'\]\s*\.\s*\'do=\w+&contenttype=\w+"\s*accesskey="\d">\'\s*\.\s*vB_Template_Runtime::parsePhrase\("\w*"\)\s*\.\s*\'</a>(</li>)*#i','',$vbulletin->templatecache['navbar']); Which searches my output for these html codes: <li class="selected"><a class="navtab" href="search.php?{vb:raw session.sessionurl}do=getnew&contenttype=vBForum_Post" accesskey="2">{vb:rawphrase getnew_tab}</a> <li class="selected"><a class="navtab" href="search.php?{vb:raw session.sessionurl}do=getdaily&contenttype=vBForum_Post" accesskey="2">{vb:rawphrase getnew_tab}</a> <li><a class="navtab" href="search.php?{vb:raw session.sessionurl}do=getnew&contenttype=vBForum_Post" accesskey="2">{vb:rawphrase getnew_tab}</a></li> <li><a class="navtab" href="search.php?{vb:raw session.sessionurl}do=getdaily&contenttype=vBForum_Post" accesskey="2">{vb:rawphrase getnew_tab}</a></li> What that does is hide those four lines and works as intended. Now what I want to do is with another option, search for those four codes, and have the output look like this: <li class="selected"><a class="navtab" href="search.php?{vb:raw session.sessionurl}do=getnew&contenttype=vBForum_Post" accesskey="2"><img src="dbtech/vbnavtabs/images/whats_new_image/whats_new.png" style="margin-bottom:.25em; vertical-align:middle;' . $image_padding . '" >{vb:rawphrase getnew_tab}</a> <li class="selected"><a class="navtab" href="search.php?{vb:raw session.sessionurl}do=getdaily&contenttype=vBForum_Post" accesskey="2"><img src="dbtech/vbnavtabs/images/whats_new_image/whats_new.png" style="margin-bottom:.25em; vertical-align:middle;' . $image_padding . '" >{vb:rawphrase getnew_tab}</a> <li><a class="navtab" href="search.php?{vb:raw session.sessionurl}do=getnew&contenttype=vBForum_Post" accesskey="2"><img src="dbtech/vbnavtabs/images/whats_new_image/whats_new.png" style="margin-bottom:.25em; vertical-align:middle;' . $image_padding . '" >{vb:rawphrase getnew_tab}</a></li> <li><a class="navtab" href="search.php?{vb:raw session.sessionurl}do=getdaily&contenttype=vBForum_Post" accesskey="2"><img src="dbtech/vbnavtabs/images/whats_new_image/whats_new.png" style="margin-bottom:.25em; vertical-align:middle;' . $image_padding . '" >{vb:rawphrase getnew_tab}</a></li> I have tried numerous ways, but can not get it to function, if someone could tell me the code I need to use as I am at a loss. Any help would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
ragax Posted December 20, 2011 Share Posted December 20, 2011 Hi ozzy47, If I have understood, you just want to insert an image tag in the other tags, is that right? This expression does it for you. The Match expression: (<li[^>]*?><a[^>]*?>)({[^<]*?</a>) The Replace expression: \1<img src="dbtech/vbnavtabs/images/whats_new_image/whats_new.png" style="margin-bottom:.25em; vertical-align:middle;' . $image_padding . '" >\2 A preg_repace that takes the $subject string as input: $result = preg_replace('%(<li[^>]*?><a[^>]*?>)(\{[^<]*?</a>)%m', '\1<img src="dbtech/vbnavtabs/images/whats_new_image/whats_new.png" style="margin-bottom:.25em; vertical-align:middle;\' . $image_padding . \'" >\2', $subject); Is this what you were looking for? Your code boxes were pretty full so I may have misunderstood. Wishing you a fun day Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.