ElmoTheClown Posted September 2, 2010 Share Posted September 2, 2010 I have news articles which I distribute to various sites. Each article contains various hyperlinks, which must resolve to a location on the site which pulled the article, i.e. Article: (hyperlink) Widgets are wonderful. Don Doe, president of (Widgets Incorporated) say they are cool. ------ Site A: To resolve to example.com/widget-companies/Widget-news/Widgets-Incorporated. Site B: To resolve to otherexample.com/Widgets-Incorporates/widget-news I'm paralyzed. The only thing I can think of is to bring the whole article in, and do a string replace. Some of the articles are 2k+ words. Even then, I have to come up with a way of pointing out the link text. I came up with $COMPANY:WIDGETS-INCORPORATED:Widget-Incorporated (UC WIDGETS to associate it with that company, and the mixed case Widget-Incorporated would be the hyperlink text. Explode it and use it. I am not even sure it will work, or if it works whether it is too inefficient. Should I try that, or something else? Quote Link to comment https://forums.phpfreaks.com/topic/212388-readingprocessing-variables-imported-from-mysql/ Share on other sites More sharing options...
samshel Posted September 2, 2010 Share Posted September 2, 2010 If i understand you, what you want is dynamic links depending upon the website calling the widget. If this is correct, you have 2 options [as far as i can think]: 1) Keep a companywise copy of your articles in the database as a cache. When you write a new article or edit an existing one, it will re-generate the cache. i.e. If you have 200 companies, it will create 200 records in cache 1 for each company with respective website specific links. For this you need to maintain a list of websites which can call your widget. This is useful when you have big articles, you dont edit/add new ones too frequently [like more than 5 time per hour or so depending on time it takes to generate the cache] and you have manageable number of companies. The cache count will be number of articles * number of companies. With this method, you dont have to do anything on the fly as you will prepare static website wise content before hand. 2) As you already thought about, the second approach would be string replace for the complete article. With 2K words i think it should still be manageable, you have to do your stats and check though. I am not sure I understood your last approach of exploding. Best of luck ! Quote Link to comment https://forums.phpfreaks.com/topic/212388-readingprocessing-variables-imported-from-mysql/#findComment-1106617 Share on other sites More sharing options...
ElmoTheClown Posted September 3, 2010 Author Share Posted September 3, 2010 lol.... I haven't a clue on how to institute #1, but thank you. With the "explode" I was figuring on exploding on ':' using the info to generate the links, with the parts being used by the individual site scripts to build the path. Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/212388-readingprocessing-variables-imported-from-mysql/#findComment-1106819 Share on other sites More sharing options...
ElmoTheClown Posted September 27, 2010 Author Share Posted September 27, 2010 Thanks for the help. I ended up using "|" to denote and split various aspects of the string, as in: |L-1|Difirent-Text| Where L (or S) denote either a company or a store, if second parameter is included, it replaces the hyoertext from the store or company name with the new text. Quote Link to comment https://forums.phpfreaks.com/topic/212388-readingprocessing-variables-imported-from-mysql/#findComment-1116350 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.