Forums » SEPHP Help and Tips

Looking for a way to modify head meta

    • 23 posts
    December 21, 2017 5:18 PM EST

    Hello,

    i need to change meta description on sites because on all pages is the same meta description.

    I am looking for a way to change the header description for some of my sites. I know that they're generated in core/default.tpl somehow here:

    <pre class="language-php"><span class="token variable">$description</span> <span class="token operator">=</span> <span class="token variable">$this</span><span class="token operator">-</span><span class="token operator">></span><span class="token function">layout</span><span class="token punctuation">(</span><span class="token punctuation"></span><span class="token operator">-</span><span class="token operator">></span><span class="token property">siteinfo</span><span class="token punctuation">[</span><span class="token string">'description'</span><span class="token punctuation">]</span><span class="token punctuation">;</span></pre>

    This is nice and easy to understand.

    But how to I change siteinfo['description'] ?

     

    What I've tried so far:

    Fo to the view.tpl of my plugin and paste this:

    <pre class="language-php"><span class="token variable">$this</span><span class="token operator">-</span><span class="token operator">></span><span class="token function">layout</span><span class="token punctuation">(</span><span class="token punctuation"></span><span class="token operator">-</span><span class="token operator">></span><span class="token property">siteinfo</span><span class="token punctuation">[</span><span class="token string">'description'</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token string">"foo"</span><span class="token punctuation">;</span></pre>

    This did not work. Is this the wrong one or is the header already printed when i run this code?

    Can you help me? I want to take the title of the site and add it into the description. When the description is to short I want to add additional text based on the total length to improve user engagement.

     

    Thanks for you help

    • Moderator
    • 4262 posts
    December 21, 2017 8:34 PM EST

    Please repost your code you had put without code tags. We require code tags for safety. The two above are fine.

    Why are you trying to change it via code instead of via the layout editor where you can change the things without having to code? Or, are you trying to change something else that isn't in the layout editor when you click to edit the page?

    • 23 posts
    December 22, 2017 9:34 AM EST

    It is not possible to change meta in the backend because pages are dynamically generated

    • 23 posts
    December 22, 2017 10:07 AM EST
    $description = $this->layout()->siteinfo['description']; $this->layout()->siteinfo['description'] = "foo";
    This post was edited by Donna at December 22, 2017 12:46 PM EST
    • Moderator
    • 4262 posts
    December 22, 2017 12:47 PM EST

    I edited your post this time to have the code tags that we require. I will have to delete it if you post code again without the required tags in our posting terms. It is very easy to use the code tags. Click the button next to smiley.

    • Moderator
    • 4262 posts
    December 22, 2017 12:49 PM EST
    asljdkfhasdf said:

    It is not possible to change meta in the backend because pages are dynamically generated

    When you are in the layout editor and click to Edit page, it has seo options there. Are those not the options you want?

    • Moderator
    • 4262 posts
    December 23, 2017 4:25 AM EST

    https://support.socialengine.com/php/customer/en/portal/articles/2496958-add-meta-tags-and-keywords-for-better-seo-of-your-site?b_id=14386 perhaps this tutorial will help as it shows where to change the meta keywords and meta description as well as site title. 

    • 23 posts
    December 23, 2017 5:33 AM EST

    No because that options are not flexible enought. How should i edit meta descriptions for 1000 pages?

    • 23 posts
    December 23, 2017 5:33 AM EST

    Where are the dev docs ?

    • Moderator
    • 4262 posts
    December 23, 2017 10:41 AM EST

    Did you read the tutorial I linked? It is for the site wide meta, not the other ones I was describing before. All documents are at our knoweldgebase linked earlier. However, we don't have a lot of developer documents. I think the SEO tutorial I linked is the one you need if you read it. 

    • 262 posts
    December 28, 2017 12:39 AM EST
    asljdkfhasdf said:

    Hello,

    i need to change meta description on sites because on all pages is the same meta description.

    I am looking for a way to change the header description for some of my sites. I know that they're generated in core/default.tpl somehow here:

    <pre class="language-php"><span class="token variable">$description</span> <span class="token operator">=</span> <span class="token variable">$this</span><span class="token operator">-</span><span class="token operator">></span><span class="token function">layout</span><span class="token punctuation">(</span><span class="token punctuation"></span><span class="token operator">-</span><span class="token operator">></span><span class="token property">siteinfo</span><span class="token punctuation">[</span><span class="token string">'description'</span><span class="token punctuation">]</span><span class="token punctuation">;</span></pre>

    This is nice and easy to understand.

    But how to I change siteinfo['description'] ?

     

    What I've tried so far:

    Fo to the view.tpl of my plugin and paste this:

    <pre class="language-php"><span class="token variable">$this</span><span class="token operator">-</span><span class="token operator">></span><span class="token function">layout</span><span class="token punctuation">(</span><span class="token punctuation"></span><span class="token operator">-</span><span class="token operator">></span><span class="token property">siteinfo</span><span class="token punctuation">[</span><span class="token string">'description'</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token string">"foo"</span><span class="token punctuation">;</span></pre>

    This did not work. Is this the wrong one or is the header already printed when i run this code?

    Can you help me? I want to take the title of the site and add it into the description. When the description is to short I want to add additional text based on the total length to improve user engagement.

     

    Thanks for you help

    Our easy-to-use and easy-to-install Social Meta Tags Plugin helps to define Social Meta Tags (such as Open Graph & Twitter Cards) for different web pages to represent the web pages attractively on social networks. Open Graphs and Twitter Cards help to enhance the search and sharing capabilities of different website content on social media channels.

    Main Plugin Page: socialengineaddons.com/socialengine-social-meta-tags-plugin

    Demo: demo.socialengineaddons.com

     


    This post was edited by Donna at December 30, 2017 9:32 AM EST