Few lines of Php

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Watch

FallenShadow

Established Member
Impact
7
I've been having an issue with maps on my site and I've figured out a solution I think will work, using regexes and a line or two or php. Problem is, though I understand how PHP works to an extent, I don't know much about writing it myself.

I was wondering if someone would be willing to help me with this issue, I'm certain it can be done with a single line, if not 2.

What I need is a line of php that searches the entire page for a specific phrase/ID and then echoes out a certain code. Example:

php searches entire page for [id=3], which would be in a post. It then takes the "id=3" part and adds it to the code it needs to echo. Which would be [mapid=3]. Thus making the map appear.

I've asked a few friends who haven't been able to help.. I really think for someone who knows php well, it shouldn't be too hard..

Any help please? I'd greatly appreciate it :)
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains — AI StorefrontUnstoppable Domains — AI Storefront
I've been having an issue with maps on my site and I've figured out a solution I think will work, using regexes and a line or two or php. Problem is, though I understand how PHP works to an extent, I don't know much about writing it myself.

I was wondering if someone would be willing to help me with this issue, I'm certain it can be done with a single line, if not 2.

What I need is a line of php that searches the entire page for a specific phrase/ID and then echoes out a certain code. Example:

php searches entire page for [id=3], which would be in a post. It then takes the "id=3" part and adds it to the code it needs to echo. Which would be [mapid=3]. Thus making the map appear.

I've asked a few friends who haven't been able to help.. I really think for someone who knows php well, it shouldn't be too hard..

Any help please? I'd greatly appreciate it :)

you can use stripos to search for your exact phrase. Don't use regex unless you have to - it is slower and has risk of error if you don't match what you thought you would.
 
0
•••
I don't know what stripos is/are, and as I said I don't know php coding to do this... would you be able/willing to assist me with this?
 
0
•••
if i understand you need:

PHP:
echo preg_replace('/id=([0-9])?/smi',"mapid=$1",$page);

or, simply for one words:

PHP:
echo str_replace('id=','mapid=',$page);
 
1
•••
Thanks for trying to help, but that didn't work. I added the line to the sidebar and it displayed nothign..

Hmm.. maybe if I be a bit more specific.

I'm using WordPress with MapPress plugin. I want the maps in the sidebar, but if I add the shortcode [mappress mapid=#] to the sidebar widget, it displays the same map on each page. I'm trying to find a way to get each page to have it's own map in the sidebar.

That's why I've been trying to use PHP to find the ID if I place it in the post, so that the map will be echoed into the sidebar

---------- Post added at 03:36 PM ---------- Previous post was at 03:02 PM ----------

I appreciate those who helped with this, but I've upgraded to MapPress Pro which has a sidebar feature for maps.

Thanks again, I appreciate it
 
0
•••
Thanks for trying to help, but that didn't work. I added the line to the sidebar and it displayed nothign..

Hmm.. maybe if I be a bit more specific.

I'm using WordPress with MapPress plugin. I want the maps in the sidebar, but if I add the shortcode [mappress mapid=#] to the sidebar widget, it displays the same map on each page. I'm trying to find a way to get each page to have it's own map in the sidebar.

That's why I've been trying to use PHP to find the ID if I place it in the post, so that the map will be echoed into the sidebar

---------- Post added at 03:36 PM ---------- Previous post was at 03:02 PM ----------

I appreciate those who helped with this, but I've upgraded to MapPress Pro which has a sidebar feature for maps.

Thanks again, I appreciate it

The plugin says you can insert the MapId on individual pages

New shortcodes with many parameters: "mapid" (to specify which map to show), "width" "height", "zoom", etc.

http://wordpress.org/extend/plugins/mappress-google-maps-for-wordpress/

Is that what you are doing and it does not work?

It isn't just PHP you are dealing with, it is Javascript and Wordpress.
 
0
•••
That option is ONLY for the MapPress Pro, it just doesn't distinguish that on the page, trust me. I've read that thing up and down a dozen times.

Either way, I've upgraded to the Pro version, so I've been able to use this feature.
 
0
•••
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover
URLs.com
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back