Jump to content

Numbered

Members
  • Posts

    310
  • Joined

  • Last visited

  • Days Won

    1

 Content Type 

Downloads

Release Notes

IPS4 Guides

IPS4 Developer Documentation

Invision Community Blog

Development Blog

Deprecation Tracker

Providers Directory

Forums

Events

Store

Gallery

Posts posted by Numbered

  1. Found one more sitemap problem.

    <lastmod>

    tag show generation time of the current sitemap file. It's right, but.. What is tell standard

    Quote

    <lastmod> optional
    Identifies the time that the corresponding Sitemap file was modified. It does not correspond to the time that any of the pages listed in that Sitemap were changed. The value for the lastmod tag should be in W3C Datetime format.

    By providing the last modification timestamp, you enable search engine crawlers to retrieve only a subset of the Sitemaps in the index i.e. a crawler may only retrieve Sitemaps that were modified since a certain date. This incremental Sitemap fetching mechanism allows for the rapid discovery of new URLs on very large sites.

    So, coming back to our case, now we have 5271 sitemap files. So google should get all of them! He get information 'it's modified! take it' and doesn't matter content inside changed or not. Moreover - inside sub-sitemap with url's we didn't have any <lastmod> tags. So google get very old url to subsitemap file, get it and see just list of urls without additional meta information.

     

    My proposal:

    add <lastmod> tag to every url inside all sub-sutemaps. It will tell google which urls contain new elements and which should be scan and it tell which one not changed and not need to re-scan => will optimize scan perfomance.

    Add <lastmod> tag to index sitemap file, which never tell date of this file generation - it should provide newer date of last modified url inside this file. With that google never download sitemap with 500 urls where no changes exist => will optimize scan perfomance.

    P.S. I'll try to create a patch. If i do this - i'll share it here (for other dev's checks and helping IPS).

    Thanks for you attension and support )

  2. Little improvement (5214 elements will update more than 3 days). So you can speed up more this. Just get time needed for one

    time php mycustomsitemapupdater.php // return something like 4 sec

    So with that you can create a cycle inside for X times to run $generator->buildNextSitemap(); For example in my case - 10 times in one minute. So for 5214 elements i will need 521 minuts for all update (~= 8 hours - not bad). 

  3. IPS Sitemap generator using special database table source for refreshing - core_sitemap.

    Primary search engine source of sitemap is url https://example.com/sitemap.php which is list of sub-sitemap files. You can see list of that files proceed for this link.

    Each of that file contain no more than 1000 urls to specail pages (profile status, topic (without number of pages or comment) and other elements, with supported sitemap as core extension).

    One of our case is forum with more than 100k topics, more than 4.2kk posts and more than 6kk users. So with simply math we have 5214 sitemap files (you can simply count number of that files with command 

    select count(*) from core_sitemap; // 5214

    Sitemap generator task run by default once per 15 minuts and update only one oldest element from that big list. With simple math we can try to answer question 'how many time we need for update everything?' (because users can post not only in newest and may post in some old topics... but.. new created topic will add to sitemap file only when ALL older files will newer than current file with new topic inside). So, how much time we need for update?

    5214*15 = 78210 minuts = 1303 hours = 54 days! 54! days! Search engine will add your newest content after 54 days after them posted. Incredible thing. Not believe? Or want to know this lag for your community? You can simple know your lag time with that sql:

    select FROM_UNIXTIME(updated,'%a %b %d %H:%i:%s UTC %Y') from core_sitemap order by updated asc limit 1; // Wed Nov 01 14:13:49 UTC 2017

    Yep.. In our case oldest file last updated in 1 November...

    What we should do for fix it? Very fast solution - create a temp file, like a 'mycustomsitemapupdater.php' with this content:

    <?php
    
    require 'init.php';
    
    $generator = new \IPS\Sitemap;
    $generator->buildNextSitemap();
    
    $last = \IPS\Db::i()->select('FROM_UNIXTIME(updated, "%a %b %d %H:%i:%s UTC %Y")', 'core_sitemap', null, 'updated asc', 1)->first();
    print_r('Oldest time now: ' . $last . PHP_EOL);

    And run it via web or cli so times, what you want (before oldest time not be so old).

    Solution for a longer time - add this script to the cron and run it every minute or, which better - change task 'sitemap generator' run time from 15 mins to one minute (but it may be not solve you special problem, if you need to update it faster - do it with smart).

    Better solution - wait for IPS updating of that system.

    Thanks for attension!

    P.S. If you read my text with negative speach - it's wrong. I love IPS and just want to make attension for that problem and help others with their large communities. ^_^

  4. 22 minutes ago, media said:

    My question is Can I check the condition of post number and display the ad in any post on posts page

    If I have 25 posts per page on post page: I would like to display the ad in first post, 5th post, 15th post and etc.

    Where should I set the condition check to check the post count # on that code

    Like if post number === 1, 6, 10 and etc.

    
    {{if (($comment->position - 1) % \IPS\Settings::i()->forums_posts_per_page === 0)}}

     

    Yes, you can :lol:. Just write your logic in that condition. As example:

    {{if (($comment->position - 1) % 5 === 0)}} // will show on 1, 6, 11, 16... every five post not depend on posts per page
    {{if (($comment->position) % 2 === 0)}} // will show on every second post: 2, 4, 6, 8, 10...
    {{if (true)}} // every post :D. perfect for money :)
    {{if (($comment->position + 1) % \IPS\Settings::i()->forums_posts_per_page === 0)}} // every last post on page (depends on number of posts per page setting)
    {{if (($comment->position - 1) % (\IPS\Settings::i()->forums_posts_per_page*2) === 0)}} // every fist post but only on 2, 4, 6.. pages

    write any condition what you want :thumbsup:

    {{if (\IPS\Member::loggedIn()->member_id === 123)}} // show something only for specific toxic member :D
    <style>body { font-family: 'Comic Sans MS'; color: pink; }</style>
    {{endif}}

     

  5. 14 hours ago, media said:

    @Upgradeovec I am so embarrassed man...

    When I paste the ad code here I took my adsense ID from the coe and when I copied from here and pasted back to my website, I forgot to put AdSense ID back on men...

    Anyway, it works like a charm... Thank you so much for your help... :)

    Glad to help ;)

    14 hours ago, media said:

    Would you please show me where exactly put the post number to show add in posts?

    
    {{if (($comment->position - 1) % \IPS\Settings::i()->forums_posts_per_page === 0)}}
    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <!-- responsive1 -->
    <ins class="adsbygoogle"
         style="display:block"
         data-ad-client="ca-pub-0000000000000000"
         data-ad-slot="5827740529"
         data-ad-format="auto"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
    {{endif}}

    Would you please edit my code and show me where I need to put number like 1, 10, 20, 30, 40 etc.

    As i see below - all worked well? Isn't it?

    I didn't know google ads platform well. But i think it don't neet to get current post number (or not?).

    Anyway - this code just check your first condition - show something (ads) when current post is first post on this page (isn't it?). You can paste inside anything without show current post number. Or, you can call {$comment->position} anywhere inside post template for return that number (to html or js calling - doesn't matter).

    I think i don't understand you well (sorry for bad english).

  6. 2 minutes ago, media said:

    Looks like it works, but not displaying ads, instead

    
    HTTP 400 error
    It’s not you, it’s this link (it appears to be broken)
    Try this
    Retype the web address
    Go back to the last page
    Search for the page

    Untitled-1.thumb.jpg.a74ceab9133c5fdc0ff80917f7ded589.jpg

    It may be some issue with ads code? Try to just show post number.

    {{if (($comment->position - 1) % \IPS\Settings::i()->forums_posts_per_page === 0)}}
    #{$comment->position}
    {{endif}}

    If that return valid value - than it's a code issue. May be it can't load from ajax response (for example, code wait for some document ready state for init some variables)

  7. 12 hours ago, media said:

    Thank you, but still to complicated for me.

    I tried to add this into template bit but did not work

    
    {{if (($comment->position - 1) % \IPS\Settings::i()->forums_posts_per_page === 0)}}
    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <!-- responsive1 -->
    <ins class="adsbygoogle"
         style="display:block"
         data-ad-client="ca-pub-0000000000000000"
         data-ad-slot="5827740529"
         data-ad-format="auto"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
    {{endif}}

     

    Yep. Because you need to define 'position' value in the parent 'forums-front-topics-topic' template. Just open it, find line with 

    {{$postCount++;}}

    (it placed inside foreach cycle) and after that line paste that:

    {{$page = (\IPS\Request::i()->page ? (\IPS\Request::i()->page - 1) * \IPS\Settings::i()->forums_posts_per_page : 0); }}
    {{$comment->position = $page + $postCount;}}

    It will define 'position' variable to $comment object, which send to post template as argument. And after that your previous code will work. Now that is var not defined and condition is always false.

  8. I solve some other thing, but it can help you, as i think.

    In forums-front-topics-topic i create new variable inside foreach cycle.

    before {{$postCount++;}}: 

    {{$page = (\IPS\Request::i()->page ? (\IPS\Request::i()->page - 1) * \IPS\Settings::i()->forums_posts_per_page : 0); }}
    {{$comment->position = $page + $postCount;}}

    this will add 'position' value to the comment object. it will move as a param to the forums-front-topics-post template.

    So inside post template you can get $comment->position value with values, contain number of current post from first page (23,24,25,26,27.. any). Your solution will be like {{if (($comment->position - 1) % \IPS\Settings::i()->forums_posts_per_page === 0)}} {$ads} {{endif}}

    Hope it help you ;)

  9. @bfarber, @Lindy - any updates? Not only for event trigger. Need some ability to hook Reactable trait methods (with and without parent calling). In some situations canReact method must working in other way (provided by plugin). And in some situations react method must worked in very other way. How i can do it now? Extend, as example, \IPS\forums\Topic\Post ? It's not clear solution and very unusable extend each react-supported types of content :(

    upd.: and some additional improvement request:

    Reactable trait method react throw \DomainExceptions only with messages like 'cannot_react', id string from stack 'react_daily_exceeded' - can you throw this exception with a some code as a second parameter (different codes, of course) - it will be more right and provide to us better solution for catch this exceptions in our hooks. Like example: try{ call_user_func('parent::react... } catch \DomainException ($e) { if ($e->code === 'something') { do_my_stuff... }

    Thanks!

×
×
  • Create New...