I want to add the ShareThis buttons for every topic on my forum. I have already modified the overall header and added the code to the head tag.
How can i modify the templates so they appear for each topic? Also is there anyway to add them to the footer of or under each topics first post rather than besides the title?
I am using PHPBB 3.1.10
Many thanks
I don't know which code fragment you are trying to inject, but I assume you have already included a link to a javascript script in your header (you can also include it in your footer instead) and now you need to add the html element of the button that triggers this script.
If you want to show something only in the topics page, then you should change the styles/your_style/template/viewtopic_body.html file. You can choose where to insert it and, depending on your style and the place, you may need to do some small modifications (e.g. using the inline style="" attribute).
If you want to show it on the footer of each post, you can try putting your element just before or after the line <!-- EVENT viewtopic_body_postrow_post_after --> in your viewtopic_body.html file. The events are like "interesting points" in the styles and you can see a list of them here.
In any case, make sure that you don't make any syntax errors (and always keep a backup). You can validate your page using the W3C validator.
Related
I'm asking for help for those who have experience in changing an html file to a php file. I've tried everything I know (and I'm not the smartest I admit) but I don't understand why the following is happening.
Currently: When viewing on mobile, the mobile menu button has gone, the toggle switch which changed prices from monthly to annually, tabs which displayed different content has gone. As a result:
If there was a toggle, both the toggle results are displayed one above the other
If there was a tab, each tab element is displayed underneath the other
The mobile menu button has gone completely
Background:
I purchased an HTML template but it turns out the seller didn't want to help. I wanted to split and convert the page into a php page as I wanted a single header/footer file which I could import. As you will see (if you check the repo) the header.php and footer.php file is getting imported into the page php file.
I created the pages by first:
Renaming the original html file to a php file
Cut the header and footer and import them back into the page php file
That's all I have done. It seemed to work, however another check (after cache cleared) I noticed the issues.
The link to the site page im referring to is:
https://blueboxhosting.co.uk/products-cloud-hosting
But if you look at any of the pages, you'll see errors on all of them now where they're should have been controls (eg toggles, mobile menu, tabs etc)
I've created a snipped so you can view the code and HOPEFULLY spot where I've been a moron:
https://bitbucket.org/snippets/bbhostinguk/7e5qxp
Any help with this would be amazing as I just can't figure it out.
Start by running the HTML generated by PHP through a validator, e.g. https://validator.w3.org/
Your code has numerous stray tags which may or may not affect the rendering.
Another tip is to comment off everything and then uncomment section by section and check when things start to break.
Here is an image of my comment format: http://oi40.tinypic.com/8w07jt.jpg
The hyperlink to each individual comment is the date and time with the url in the format of, for example: /nottingham/#comment-184
After going through my comment templates I found that these two functions do the following,
get_comments_link : Retrieves the link to the current post comments
AND
comments_link: Displays the link to the current post comments
The problem is I have no idea where to include these functions so it creates a hyperlink to every comment within every comment. Once this link has been created I'd also like to assign a div to it so I can format it to be in the bottom right corner of each comment.
My final goal is to manipulate the link so rather than the comment link itself it will automatically work in the facebook.com/sharer.php which I feel I can do myself once I figure out the previous part. Essentially it will be a share on facebook button, but I have found no plugins which do this yet and thought describing it as a hyperlink would be an easier way to explain what I'm trying to do.
Elsewhere I've been told the following: but not sure how to implement this...
In functions.php I'd add a 'get_comments_link' filter to return the desired link, including the tag you need. Note that this is a filter, not a function. There is function with the same name, but it's part of WordPress itself. Use the filter to add a div to the existing link. Then style the new div to position it where you want it. I notice that the Photoria theme repositions the Reply link, which is coded at the bottom but displayed at the top. In the same way, your new will be coded at the top but displayed at the bottom. Also see add_filter in the Codex. Add the new div to $link before returning it. The new div will need a class attribute so that you can work with it in CSS to make it look the way you want.
I hope I've made the question clear, please ask if I haven't. Thanks in advance!
You need to edit your comment template in your Wordpress theme.
Default is located in /comments.php
Some more informations could be found here : http://codex.wordpress.org/Function_Reference/comments_template
Finally answered it myself, the code used to display the comment link was:
<img src=""
Which was inserted in my comments template file within my comments body div which I then put into another div so I could format it itself to where I wanted it positioned.
Currently in the process of making the link automatically share through the facebook sharer...
Hope this helps anyone with the same problem.
In the site i'm developing i would like to have users set their own custom "css" on their profile pages.
For example, i give users the ability to select a background color for <body> with a js color picker.
Then with php i create a 'css-ready' string and save it on db.
What i am asking is: how i can make this css apply everytime a user enter another user profile?
Probably will be there a lot of thing a user can customize, so there will be a big css string and i need something that will be cross browser and if possible that work also without javascript..
Thank you.
You could try a php file with header for content-type text/css which echos the CSS according to one fetched from Database, you could add default CSS to your website and just create a last in list of link tags the path to that php files, this way you have a default CSS to fall back and customized CSS to be applied on top of default if defined any..
This can be done with Handler in asp.net. I am sure there will be similar solution available in PHP also. First you need to save the style properties in a database for each user. Make sure that the syntax of the styles (selector name, curly brackets, semi-colons, etc.) are in order. You can get the user information from session object or pass the variable with query string to the handler.
The response received from the handler can directly be put between tags as content type - text/css like this:
And with this you should be ready to go!
However, it will lead to performance losses as everytime the page loads, the entire file will be loaded (in normal css file, it is loaded only once). It will be a better idea to save only those items in database which you really want your user to customise. You may cascade it with your parent css file for better performance.
you can use this is user-profile.tpl.php
<?php
if(isset($account->user_css)){
?>
<style>
<?php echo $account->user_css; ?>
</style>
<?php
}
?>
I have a webpage. On it there is a javascript warning to the users who have javascript disabled. This is in the body part of the html page, towards the top. In google this is what shows in the description!
How can I make this go to the bottom of the page to stop google using it as the descriptiuon?
It is in a class if that helps...
If you move the warning to the bottom of the code you can use absolute positioning (or fixed if you want it to scroll with the page) to have it display at the top of the page. This way it is not the first text that Google sees when it indexes the page. Along with that I would add in the meta description tag as Christopher McCann said.
Have you set a meta description tag? Do you have other content on the page?
You can't MAKE google choose what it displays as the description but it will usually use the meta description tag so make sure you have one set. It won't fix straight away - you will need to wait until Google re-crawls your website.
How can I give the user the ability to change the style of a webpage, of course I have to make several CSS files , but how can I make the code that permits the change upon the user's choice
We're all pretty unlikely to give an answer as thorough as A List Apart's.
They even provided some freely-usable code for you.
You would basically have css classes for all the major components of the page such as header, content, footer, nav_menu items, heading, etc. Everything that you want the user to be able to customize you would create a css class/ID for it.
Then you would show all these classes to the user and let him either type in the CSS code manually, or show him dropdown boxes with all the possible colors, for example, or other settings.
When the user changes an option, you could use javascript to change that property of the css ID/class he selected. E.g if he changes the background color of the header from black to blue, you could do this:
document.getElementById("header").style.background-color="#ABCDEF";
(Jquery might have an easier way of doing this)
At the end of the page you could have a submit button which would POST all the css settings to a php script, which would write these settings to the database. Then you would do a query like:
SELECT css_id,css_class,css_code FROM css_styles WHERE user_id='$user_id';
This would return all the css code, and then you would put this in the <head> command instead of an external css file.