In my recent post: Google AdSense Now Logs Into Your Sites I mentioned that displaying a quick preview of your content might be useful in some scenarios. अपनी साइट में अपने हाल ही के पोस्ट में मुझे लगता है कि आपकी सामग्री की एक त्वरित पूर्वावलोकन प्रदर्शित कुछ स्थितियों में उपयोगी हो सकता है उल्लेख किया है: गूगल ऐडसेंस अब लॉग करता है. Particularly if you want to charge subscription fees for full content. I’ll illustrated with an example so you can get an idea of where to start in accomplishing this with your own sites. खासकर अगर आप पूरी सामग्री के लिए सदस्यता शुल्क चार्ज करना चाहता हूँ. ताकि आप जहां अपनी खुद की साइटों के साथ इस accomplishing में शुरू करने के एक विचार हो सकता है मैं एक उदाहरण के साथ सचित्र हूँ. The key component in making this work is the substr ($content,0,300) function. इस काम को substr ($ सामग्री, 0300) समारोह है बनाने में मुख्य घटक. You specify the length of content by declaring a start (0) and the end (300). तुम एक शुरू (0) और अंत (300) की घोषणा के द्वारा सामग्री की लंबाई निर्दिष्ट करें. You can then output a shortened version of $content and store it in a separate variable. निर्गम $ का एक छोटा संस्करण तुम कर सकते हैं तो सामग्री और यह दुकान एक अलग चर में. Great to use as a “preview” for your content. महान अपनी सामग्री के लिए एक "पूर्वावलोकन" के रूप में उपयोग करने के लिए. Note: the number refers to the numbers of characters in the provided string, not words. नोट: इस संख्या को प्रदान की स्ट्रिंग में वर्णों की संख्या, नहीं शब्दों को संदर्भित करता है.

What you need to do is figure out the existing variables you’re outputting on each content page (likely found within your template). तुमने ऐसा करने के लिए आप प्रत्येक सामग्री पृष्ठ पर outputting हो मौजूदा चर पता है क्या ज़रूरत है (संभावना अपने टेम्पलेट के भीतर) पाया. This part goes beyond the scope of this article. इस भाग के इस लेख के दायरे से परे चला जाता है. All sites are set up with slightly differently variables and even grab content from different sources…this is not an exact science. सभी साइटों से थोड़ा अलग चर और यहां तक कि विभिन्न स्रोतों से सामग्री को हड़पने के साथ स्थापित कर रहे हैं ... यह एक सटीक विज्ञान नहीं है.

I will assume your data is coming from a mySQL database and $id is a number that refers to a row of content in your database. मैं एक MySQL डाटाबेस से आ रही है आपके डेटा की कल्पना करेंगे और $ id कि सामग्री की एक पंक्ति करने के लिए अपने डेटाबेस में संदर्भित एक संख्या है. This first snippet shows a row being queried in preparation for it to be cut down into a preview. यह पहला टुकड़ा के लिए यह एक पूर्वावलोकन में कटौती होने की तैयारी में queried की जा रही एक पंक्ति प्रदर्शित करता है.

  1. $result = mysql_query ( "SELECT id,content FROM table WHERE id={$id}" , $db ) ; id चुनें $result = mysql_query ( "SELECT id,content FROM table WHERE id={$id}" , $db ) ;
  2. $row = mysql_fetch_row ( $result ) ;
  3. echo $row [ 0 ] ; //The value of id / / echo $row [ 0 ] ; //The value of id
  4. echo $row [ 1 ] ; //The value of content
  5. $content = $row [ 1 ] ; //Store it into something we can identify easily

This is even easier when you already have your content in a string. यह भी जब आप पहले से ही अपनी सामग्री है एक स्ट्रिंग में आसान हो जाता है. In that case you wouldn’t have to run a query on it again. उस मामले में तुम फिर से उस पर एक क्वेरी चलाने के लिए नहीं होता. There are also applications in which you would want to have this preview show before you content. वहाँ भी जो में आप से पहले इस सामग्री का पूर्वावलोकन दिखाता है चाहेगा आवेदन कर रहे हैं. In that case you would only need to integrate something like this into your templates (and yes there is more then one way to do this): उस मामले में आप केवल इस तरह से अपने टेम्पलेट में कुछ को एकीकृत करने की आवश्यकता होगी (और हाँ वहाँ ऐसा करने के लिए और अधिक तो एक ही रास्ता है):

  1. $previewcontent = substr ( $content , 0 , 300 ) ;
  2. if ( isset ( $go ) ) { //If set then they have seen the preview already अगर if ( isset ( $go ) ) { //If set then they have seen the preview already
  3. echo $content ; //Display your usual content प्रदर्शित करें echo $content ; //Display your usual content
  4. } else { //First time viewing this page
  5. echo "Article preview:<br><br>" . $previewcontent ;
  6. echo "See this entire post<a href= \" showcontent.php?id=" . $id . "&go=yes \" >here</a>" ;
  7. //Or you could add something like this (instead of lines 6 & 7) for paid/subscription content 6 //Or you could add something like this (instead of lines 6 & 7) for paid/subscription content
  8. if ( isset ( $user ) ) { //If a user is logged in… अगर if ( isset ( $user ) ) { //If a user is logged in…
  9. echo "Go ahead and <a href= \" showcontent.php?id=" . $id . "&go=yes \" >view</a>" ;
  10. } else { //$user is not set - insert login/signup link/form below
  11. echo "To view this solution please click <a href= \" yoursignupscript.php \" >here</a> to purchase access." ; a> echo "To view this solution please click <a href= \" yoursignupscript.php \" >here</a> to purchase access." ;
  12. }

In my alternate configuration where visitors need to purchase access you should also change your first if statement to check if a user is logged in by doing: मेरे वैकल्पिक विन्यास में, जहां आगंतुकों यदि किसी उपयोगकर्ता द्वारा लॉग इन में क्या कर रही है तुम भी अपने यदि बयान की जाँच करने के लिए पहले बदलना चाहिए खरीद का उपयोग करने की आवश्यकता है:
if(isset($go) && isset($user)) (isset ($ जाना) & & isset ($ उपयोगकर्ता)) अगर

There’s some security and usability you need to consider when implementing this which I didn’t get into. वहां कुछ सुरक्षा और प्रयोज्य तुम जब मैं इस में जो नहीं मिला को लागू करने पर विचार करने की आवश्यकता है. As shown above isset () is another very handy function in php as it allows you to set triggers in conjunction with if statements. के रूप में इसे आप सेट करने की अनुमति देता है जैसा कि isset से ऊपर () है php में एक और बहुत ही आसान समारोह में दिखाया अगर बयानों के साथ संयोजन के रूप में triggers. This can make a webpage very dynamic. यह एक वेबपेज बहुत गतिशील कर सकते हैं.

If you’re not that far yet with a coding language, I hope this at least gives you some ideas of what you can do. For additional help check out php.net: http://us3.php.net/substr . यदि आपको लगता है कि दूर अभी तक एक कोडन भाषा के साथ नहीं है, मैं कम से कम आप क्या कर सकते के कुछ विचारों देता है इस उम्मीद है. बाहर अतिरिक्त मदद की जाँच के लिए php.net: http://us3.php.net/substr. Just getting started with php/mySQL?: Increase Earning Potential With These PHP/mySQL Tutorials सिर्फ php के साथ शुरू हो रही / MySQL?: बढ़ाएँ अर्जन ये php के साथ संभावित / MySQL Tutorials



Leave A Comment: एक टिप्पणी को छोड़ दें:

Comments RSS Feed टिप्पणियाँ RSS फ़ीड

6 - 1 = 6 - 1 =

Custom Theme by Rob Malon | Content & Design © 2008 - Rob Malon [dot] Com. कस्टम थीम रोब Malon द्वारा | सामग्री व डिजाइन © 2008 - रोब Malon [डॉट] com. "));
"));