Jump to content

Reading/processing variables imported from MySQL


ElmoTheClown

Recommended Posts

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?

Link to comment
Share on other sites

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 !

Link to comment
Share on other sites

  • 4 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.