Using CSS or other to format instance of a specific word

Discussion in 'Programming' started by Trefethen, Sep 3, 2009.

  1. #1
    I need a way to format a specific word, or sentence containing a specific word, within a lot of text in a web page. I am not a programmer and would love it if there was a way to achieve this using CSS, so that whenever any new text is added to a new document associated with a certain style sheet, all instanced of a certain word would be automatically formatted in this way.

    For example, in the text that follows the word "hope" appears. In this text I would like each instance of the word hope to be formatted in such a way as to call more attention to it, bold, larger, colored, etc.

    With treatment, more than 80% of people with depression respond favorably to medications, and the feeling of hopelessness subsides. With treatment, most people are able to resume their normal work and social activities. Symptoms of a depressive disorder include at least five of the following changes in the individual's previous characteristics: loss of motivation and inability to feel pleasure; deep chronic sadness or distress; changes in sleep patterns; lack of physical energy (apathy); feelings of hopelessness and worthlessness; difficulty with concentration; overeating or loss of appetite; withdrawal from interpersonal interactions or avoidance of others; death wishes, or belief in his/her own premature death. In children, the first signs of depression may be irritation and loss of concentration, apathy and distractibility during classes, and social withdrawal. Some adults initially complain of constant fatigue, even after long hours of sleep, digestive disorders, headaches, anxiety, recurrent memory lapses, and insomnia or excessive sleeping. An episode of major depression may be preceded by a period of dysthymia, a mild but persistent low mood state, usually accompanied by diminished sexual drive, decreased affective response, and loss of interest in normal social activities and hobbies.​

    What I am trying to do is figure out a way to capture a bunch of text about a certain topic, pull that text into a document automatically, then repost it to a web page with formatted text.

    Here are a couple of samples:
    http://wr.trefethenstudios.com/Facebook_Asain/index.html
    http://wr.trefethenstudios.com/FB/index.html
     
    Trefethen, Sep 3, 2009 IP
  2. HomeComputerGames

    HomeComputerGames Peon

    Messages:
    871
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If your site uses PHP you can filter your text and use pattern matching to replace what you are looking for.
    Here I search through my Product Reviews for the product title. The product name is contained in the variable $products_name and I bold, plus italics it in the Customer Review. So everytime there is mention of the product in the review it is bolded and italic. I do this for other words also and have some that will make the chosen word link back to wherever I desire:

    $products_reviews = str_replace($products_name , '<b><i>'.$products_name.'</i></b>' , $products_reviews);
     
    HomeComputerGames, Sep 3, 2009 IP
  3. Trefethen

    Trefethen Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This is great information. However, I am not a programmer, and therefore would not know how to implement your script. My site does run PHP 4.0.

    Is this script something I would simply include in the header area of a PHP doc. Sorry for the newby question, but like I said I have no PHP background.
     
    Trefethen, Sep 8, 2009 IP